示例#1
0
        public static Sprite Create(Texture2D texture, Rect rect, Vector2 pivot, float pixelsPerUnit, uint extrude, SpriteMeshType meshType, Vector4 border, bool generateFallbackPhysicsShape)
        {
            bool   flag = texture == null;
            Sprite result;

            if (flag)
            {
                result = null;
            }
            else
            {
                bool flag2 = rect.xMax > (float)texture.width || rect.yMax > (float)texture.height;
                if (flag2)
                {
                    throw new ArgumentException(string.Format("Could not create sprite ({0}, {1}, {2}, {3}) from a {4}x{5} texture.", new object[]
                    {
                        rect.x,
                        rect.y,
                        rect.width,
                        rect.height,
                        texture.width,
                        texture.height
                    }));
                }
                bool flag3 = pixelsPerUnit <= 0f;
                if (flag3)
                {
                    throw new ArgumentException("pixelsPerUnit must be set to a positive non-zero value.");
                }
                result = Sprite.CreateSprite(texture, rect, pivot, pixelsPerUnit, extrude, meshType, border, generateFallbackPhysicsShape);
            }
            return(result);
        }