Esempio n. 1
0
    public static Vector2 GetGlobalTextureRectMaxes(this FSprite sprite)
    {
        Vector2[] vectors = sprite.textureRect.GetCoordinates();

        vectors[0] = sprite.LocalToGlobal(vectors[0]);
        vectors[1] = sprite.LocalToGlobal(vectors[1]);
        vectors[2] = sprite.LocalToGlobal(vectors[2]);
        vectors[3] = sprite.LocalToGlobal(vectors[3]);

        float maxX = -1000000;
        float maxY = -1000000;

        maxX = Mathf.Max(maxX, vectors[0].x);
        maxX = Mathf.Max(maxX, vectors[1].x);
        maxX = Mathf.Max(maxX, vectors[2].x);
        maxX = Mathf.Max(maxX, vectors[3].x);

        maxY = Mathf.Max(maxY, vectors[0].y);
        maxY = Mathf.Max(maxY, vectors[1].y);
        maxY = Mathf.Max(maxY, vectors[2].y);
        maxY = Mathf.Max(maxY, vectors[3].y);

        return(new Vector2(maxX, maxY));
    }
Esempio n. 2
0
    public static Vector2 GetGlobalTextureRectMins(this FSprite sprite)
    {
        Vector2[] vectors = sprite.textureRect.GetCoordinates();

        vectors[0] = sprite.LocalToGlobal(vectors[0]);
        vectors[1] = sprite.LocalToGlobal(vectors[1]);
        vectors[2] = sprite.LocalToGlobal(vectors[2]);
        vectors[3] = sprite.LocalToGlobal(vectors[3]);

        float minX = 1000000;
        float minY = 1000000;

        minX = Mathf.Min(minX, vectors[0].x);
        minX = Mathf.Min(minX, vectors[1].x);
        minX = Mathf.Min(minX, vectors[2].x);
        minX = Mathf.Min(minX, vectors[3].x);

        minY = Mathf.Min(minY, vectors[0].y);
        minY = Mathf.Min(minY, vectors[1].y);
        minY = Mathf.Min(minY, vectors[2].y);
        minY = Mathf.Min(minY, vectors[3].y);

        return(new Vector2(minX, minY));
    }