示例#1
0
    static public void RecalculateFOV(Camera camera, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (camera == null)
        {
            return;
        }

        camera.fieldOfView = RecalculateValue(camera.fieldOfView, factorType);
        camera.fieldOfView = RoundFloat(camera.fieldOfView, roundPreference);
    }
示例#2
0
    static public void RecalculateSizeText(tk2dTextMesh label, SizeFactor type, RoundFloatEnum roundPreference)
    {
        if (label == null)
        {
            return;
        }

        label.scale = RecalculateByFactor(label.scale, type);
        label.scale = RoundVector3(label.scale, roundPreference);
    }
示例#3
0
    static public void RecalculateSizeSlicedSprite(tk2dSlicedSprite sprite, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (sprite == null)
        {
            return;
        }

        sprite.dimensions = RecalculateByFactor(sprite.dimensions, factorType);
        sprite.dimensions = RoundVector2(sprite.dimensions, roundPreference);
    }
示例#4
0
    static public void RecalculateSizeGradientQuad(GradientQuad quad, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (quad == null)
        {
            return;
        }

        quad.Size = RecalculateByFactor(quad.Size, factorType);
        quad.Size = RoundVector2(quad.Size, roundPreference);
    }
示例#5
0
    static public void RecalculateScale(Transform transform, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (transform == null)
        {
            return;
        }

        transform.localScale = RecalculateByFactor(transform.localScale, factorType);
        transform.localScale = RoundVector3(transform.localScale, roundPreference);
    }
示例#6
0
    static public void RecalculateSizeSprite(tk2dBaseSprite sprite, SizeFactor factorType, Fit fitType, RoundFloatEnum roundPreference)
    {
        if (sprite == null)
        {
            return;
        }

        sprite.scale = RecalculateByFactor(sprite.scale, factorType);
        sprite.scale = RecalculateByFit(sprite.scale, fitType, true);
        sprite.scale = RoundVector3(sprite.scale, roundPreference);
    }
示例#7
0
    static public void RecalculateMask(tk2dUIMask mask, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (mask == null)
        {
            return;
        }

        mask.size = RecalculateByFactor(mask.size, factorType);
        mask.size = RoundVector2(mask.size, roundPreference);
        mask.Build();
    }
示例#8
0
    static public void RecalculateSizeParticleSystem(ParticleSystem particleSystem, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (particleSystem == null)
        {
            return;
        }

        RecalculateScale(particleSystem.transform, factorType, roundPreference);
        particleSystem.startSize = RecalculateValue(particleSystem.startSize, factorType);
        particleSystem.startSize = RoundFloat(particleSystem.startSize, roundPreference);
    }
示例#9
0
    static public void RecalculateCollider(BoxCollider collider, SizeFactor factorType, Fit fitType, RoundFloatEnum roundPreference)
    {
        if (collider == null)
        {
            return;
        }

        collider.size   = RecalculateByFactor(collider.size, factorType);
        collider.size   = RecalculateByFit(collider.size, fitType, false);
        collider.size   = RoundVector3(collider.size, roundPreference);
        collider.center = RecalculateByFactor(collider.center, factorType);
        collider.center = RoundVector3(collider.center, roundPreference);
    }
示例#10
0
    static public void RecalculateGrid(Grid grid, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (grid == null)
        {
            return;
        }

        Vector2 distance = new Vector2(grid.cellWidth, grid.cellHeight);

        distance        = RecalculateByFactor(distance, factorType);
        distance        = RoundVector2(distance, roundPreference);
        grid.cellWidth  = distance.x;
        grid.cellHeight = distance.y;
    }
示例#11
0
    static public void RecalculateSizeParticleSystem(ParticleSystem particleSystem, SizeFactor factorType, RoundFloatEnum roundPreference)
    {
        if (particleSystem == null)
        {
            return;
        }

        RecalculateScale(particleSystem.transform, factorType, roundPreference);

        #if UNITY_5_5_OR_NEWER
        var main = particleSystem.main;
        main.startSizeMultiplier = RecalculateValue(main.startSizeMultiplier, factorType);
        main.startSizeMultiplier = RoundFloat(main.startSizeMultiplier, roundPreference);
        #else
        particleSystem.startSize = RecalculateValue(particleSystem.startSize, factorType);
        particleSystem.startSize = RoundFloat(particleSystem.startSize, roundPreference);
        #endif
    }
示例#12
0
    static Vector3 RecalculateByFactor(Vector3 baseValue, SizeFactor type)
    {
        if (type == SizeFactor.MaxFactor)
        {
            baseValue.x *= MaxFactor;
            baseValue.y *= MaxFactor;
        }
        else if (type == SizeFactor.MinFactor)
        {
            baseValue.x *= MinFactor;
            baseValue.y *= MinFactor;
        }
        else if (type == SizeFactor.TwoFactor)
        {
            baseValue.x *= WidthFactor;
            baseValue.y *= HeightFactor;
        }
        else if (type == SizeFactor.HeightFactor)
        {
            baseValue.x *= HeightFactor;
            baseValue.y *= HeightFactor;
        }
        else if (type == SizeFactor.WidthFactor)
        {
            baseValue.x *= WidthFactor;
            baseValue.y *= WidthFactor;
        }
        else if (type == SizeFactor.MirrorTwoFactor)
        {
            baseValue.x *= HeightFactor;
            baseValue.y *= WidthFactor;
        }
        else if (type == SizeFactor.OnlyHeightFactor)
        {
            baseValue.y *= HeightFactor;
        }
        else if (type == SizeFactor.OnlyWidhtFactor)
        {
            baseValue.x *= WidthFactor;
        }

        return(baseValue);
    }
示例#13
0
    static float RecalculateValue(float value, SizeFactor factorType)
    {
        if (factorType == SizeFactor.MaxFactor)
        {
            value *= MaxFactor;
        }
        else if (factorType == SizeFactor.MinFactor)
        {
            value *= MinFactor;
        }
        else if (factorType == SizeFactor.HeightFactor)
        {
            value *= HeightFactor;
        }
        else if (factorType == SizeFactor.WidthFactor)
        {
            value *= WidthFactor;
        }

        return(value);
    }
示例#14
0
        public void GetFactorTest_Success()
        {
            //Arrange:
            var referenceHeight = new Mock <IFactor>();

            referenceHeight.Setup(rh => rh.GetFactor()).Returns(2);
            var windLoadData = new Mock <IWindLoadData>();

            windLoadData.Setup(wld => wld.GetTurbulenceIntensityAt(2, false)).Returns(3);
            var backgroundFactor = new Mock <IFactor>();

            backgroundFactor.Setup(bf => bf.GetFactor()).Returns(5);

            var sizeFactor = new SizeFactor(referenceHeight.Object,
                                            windLoadData.Object,
                                            backgroundFactor.Object);

            //Act:
            var result = sizeFactor.GetFactor();

            //Assert:
            Assert.That(result, Is.EqualTo(2.179883).Within(0.000001));
        }
示例#15
0
    static public void RecalculateSizeSpriteFromTexture(tk2dSpriteFromTexture spriteFromTexture, SizeFactor factorType, Fit fitType, RoundFloatEnum roundPreference)
    {
        if (spriteFromTexture == null)
        {
            return;
        }

        spriteFromTexture.ForceBuild();
        RecalculateSizeSprite(spriteFromTexture.GetComponent <tk2dBaseSprite>(), factorType, fitType, roundPreference);
    }
示例#16
0
 static public Vector3 RecalculatePosition(Vector3 position, SizeFactor factorType, RoundFloatEnum roundPreference = RoundFloatEnum.DontRoundFloat)
 {
     return(RoundVector3(RecalculateByFactor(position, factorType), roundPreference));
 }