Esempio n. 1
0
        public Sprite GetSprite()
        {
            var sprite = GetImporter().GetImportingSprite();

            if (sprite == null)
            {
                sprite = SVGImporter.GetImportedSprite(GetImporter().assetPath);
            }
            return(sprite);
        }
Esempio n. 2
0
        public Texture2D GetTexture2D()
        {
            var tex = GetImporter().GetImportingTexture2D();

            if (tex == null)
            {
                tex = SVGImporter.GetImportedTexture2D(GetImporter().assetPath);
            }
            return(tex);
        }
Esempio n. 3
0
        public override Texture2D RenderStaticPreview(string assetPath, UnityEngine.Object[] subAssets, int width, int height)
        {
            var sprite = SVGImporter.GetImportedSprite(assetTarget);

            if (sprite == null)
            {
                return(null);
            }

            return(BuildPreviewTexture(sprite, width, height));
        }
Esempio n. 4
0
        public override string GetInfoString()
        {
            var sprite = SVGImporter.GetImportedSprite(assetTarget);

            if (sprite == null)
            {
                var tex = assetTarget as Texture2D;
                if (tex == null)
                {
                    return("");
                }
                return(InternalEditorBridge.GetTextureInfoString(tex));
            }

            int vertexCount = sprite.vertices.Length;
            int indexCount  = sprite.triangles.Length;

            var stats = "" + vertexCount + " Vertices (Pos";

            int vertexSize = sizeof(float) * 2;

            if (sprite.HasVertexAttribute(VertexAttribute.Color))
            {
                stats      += ", Col";
                vertexSize += 4;
            }
            if (sprite.HasVertexAttribute(VertexAttribute.TexCoord0))
            {
                stats      += ", TexCoord0";
                vertexSize += sizeof(float) * 2;
            }
            if (sprite.HasVertexAttribute(VertexAttribute.TexCoord1))
            {
                stats      += ", TexCoord1";
                vertexSize += sizeof(float) * 2;
            }
            if (sprite.HasVertexAttribute(VertexAttribute.TexCoord2))
            {
                stats      += ", TexCoord2";
                vertexSize += sizeof(float) * 2;
            }

            stats += ") " + HumanReadableSize(vertexSize * vertexCount + indexCount * 2);

            return(stats);
        }
Esempio n. 5
0
        public void Load(SerializedObject so)
        {
            var importer = so.targetObject as SVGImporter;
            var sprite   = SVGImporter.GetImportedSprite(importer.assetPath);

            if (sprite == null)
            {
                return;
            }

            SpriteRect.name = sprite.name;

            int targetWidth;
            int targetHeight;

            importer.TextureSizeForSpriteEditor(sprite, out targetWidth, out targetHeight);
            SpriteRect.rect = new Rect(0, 0, targetWidth, targetHeight);
            var textureSize = new Vector2(targetWidth, targetHeight);

            var baseSP       = so.FindProperty("m_SpriteData");
            var spriteRectSP = baseSP.FindPropertyRelative("SpriteRect");

            SpriteRect.border = spriteRectSP.FindPropertyRelative("m_Border").vector4Value;
            SpriteRect.pivot  = sprite.pivot / textureSize;

            var guidSP = spriteRectSP.FindPropertyRelative("m_SpriteID");

            SpriteRect.spriteID = new GUID(guidSP.stringValue);

            SpriteRect.alignment = SpriteAlignment.Center;
            if (Enum.IsDefined(typeof(SpriteAlignment), (int)importer.Alignment))
            {
                SpriteRect.alignment = (SpriteAlignment)importer.Alignment;
            }
            else if (importer.Alignment == VectorUtils.Alignment.SVGOrigin)
            {
                SpriteRect.alignment = SpriteAlignment.Custom;
            }
            m_PrevAlignment = SpriteRect.alignment;
            m_PrevPivot     = SpriteRect.pivot;
        }
Esempio n. 6
0
 public SVGDataProviderBase(SVGImporter importer)
 {
     m_Importer = importer;
 }
Esempio n. 7
0
 public SVGPhysicsOutlineDataProvider(SVGImporter importer) : base(importer)
 {
 }
Esempio n. 8
0
 public Texture2D GetReadableTexture2D()
 {
     if (m_ReadableTexture == null)
     {
         if (GetImporter().SvgType == SVGType.VectorSprite)
         {
             var sprite = GetSprite();
             var size   = ((Vector2)sprite.bounds.size) * sprite.pixelsPerUnit;
             m_ReadableTexture = VectorUtils.RenderSpriteToTexture2D(sprite, (int)size.x, (int)size.y, SVGImporter.GetSVGSpriteMaterial(sprite), 4);
         }
         else
         {
             return(GetTexture2D());
         }
     }
     return(m_ReadableTexture);
 }
Esempio n. 9
0
 public SVGTextureDataProvider(SVGImporter importer) : base(importer)
 {
 }
Esempio n. 10
0
 internal static Texture2D BuildPreviewTexture(Sprite sprite, int width, int height)
 {
     return(VectorUtils.RenderSpriteToTexture2D(sprite, width, height, SVGImporter.GetSVGSpriteMaterial(sprite), 4));
 }