Exemple #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);
    }
Exemple #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);
    }
Exemple #3
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);
    }
Exemple #4
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();
    }
Exemple #5
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;
    }
Exemple #6
0
 static float RoundFloat(float value, RoundFloatEnum roundPreference)
 {
     switch (roundPreference)
     {
     case RoundFloatEnum.RoundToInteger:
     case RoundFloatEnum.RoundTo1DiginAfterPoint:
     case RoundFloatEnum.RoundTo2DiginAfterPoint:
     case RoundFloatEnum.RoundTo3DiginAfterPoint:
     case RoundFloatEnum.RoundTo4DiginAfterPoint:
         value *= Mathf.Pow(10f, ((int)roundPreference));
         value  = (int)((Mathf.Abs(value) + 0.5f) * Mathf.Sign(value));
         value /= Mathf.Pow(10f, ((int)roundPreference));
         break;
     }
     return(value);
 }
Exemple #7
0
 static Vector3 RoundVector3(Vector3 vector, RoundFloatEnum roundPreference)
 {
     switch (roundPreference)
     {
     case RoundFloatEnum.RoundToInteger:
     case RoundFloatEnum.RoundTo1DiginAfterPoint:
     case RoundFloatEnum.RoundTo2DiginAfterPoint:
     case RoundFloatEnum.RoundTo3DiginAfterPoint:
     case RoundFloatEnum.RoundTo4DiginAfterPoint:
         vector.Scale(Vector3.one * Mathf.Pow(10f, ((int)roundPreference)));
         for (int i = 0; i < 3; i++)
         {
             vector[i] = (int)((Mathf.Abs(vector[i]) + 0.5f) * Mathf.Sign(vector[i]));
         }
         vector.Scale(Vector3.one / Mathf.Pow(10f, ((int)roundPreference)));
         break;
     }
     return(vector);
 }
Exemple #8
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);
    }
Exemple #9
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);
    }
Exemple #10
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);
    }
Exemple #11
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);
    }
Exemple #12
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
    }
Exemple #13
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);
    }
Exemple #14
0
 static public Vector3 RecalculatePosition(Vector3 position, SizeFactor factorType, RoundFloatEnum roundPreference = RoundFloatEnum.DontRoundFloat)
 {
     return(RoundVector3(RecalculateByFactor(position, factorType), roundPreference));
 }
Exemple #15
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);
    }