Пример #1
0
    public static E2DMatrix3x2 FromE2DImage(E2DUIComponent com, E2DSprite e2DSprite)
    {
        //根据图片组件的sizeDelta和scale计算最终缩放值
        var finalScale = new Vector3(com.node.sizeDelta.x / e2DSprite.w * com.e2dScale.x,
                                     com.node.sizeDelta.y / e2DSprite.h * com.e2dScale.y, 1);

        return(FromTRS(com.e2dPos, com.e2dRot, finalScale));
    }
Пример #2
0
 public E2DButton(E2DSprite e2DSprite, Button btn, RectTransform root)
 {
     this.root      = root;
     this.node      = btn.image.rectTransform;
     this.e2DSprite = e2DSprite;
     this.id        = e2DSprite.id;
     this.btn       = btn;
     this.name      = btn.name;
 }
Пример #3
0
 public E2DImage(E2DSprite e2DSprite, Image image, E2DWidget container, RectTransform root)
 {
     this.root      = root;
     this.node      = image.rectTransform;
     this.image     = image;
     this.id        = e2DSprite.id;
     this.name      = image.name;
     this.container = container;
 }
Пример #4
0
    public E2DPackage(string package, string defaultSpriteName, Texture2D[] textures)
    {
        this.name = package;

        this.textures = new List <Texture2D>();
        for (int i = 0; i < textures.Length; i++)
        {
            if (textures[i] != null)
            {
                this.textures.Add(textures[i]);
            }
        }

        //读取相关图集的所有Sprite
        List <Sprite> allSprites = new List <Sprite>();

#if UNITY_EDITOR
        foreach (var texture in this.textures)
        {
            var objs = AssetDatabase.LoadAllAssetRepresentationsAtPath(AssetDatabase.GetAssetPath(texture));
            foreach (var o in objs)
            {
                var sprite = o as Sprite;
                if (sprite != null)
                {
                    allSprites.Add(sprite);
                    if (sprite.name == defaultSpriteName)
                    {
                        this.defaultSprite = sprite;
                    }
                }
            }
        }
#endif

        this.sprites      = new List <E2DSprite>(allSprites.Count);
        this.spriteRefMap = new Dictionary <Sprite, E2DSprite>();
        for (int i = 0; i < allSprites.Count; i++)
        {
            var sprite    = allSprites[i];
            var e2dSprite = new E2DSprite(sprite, this.textures, E2DExportSpriteData.Instance.Contain(sprite));
            this.sprites.Add(e2dSprite);
            RegisterCom(e2dSprite);
            spriteRefMap.Add(sprite, e2dSprite);
        }

        this.widgets  = new List <E2DWidget>();
        this.uiRefMap = new Dictionary <string, E2DWidget>();

        this.fontStyles  = new List <E2DFontStyle>();
        this.rawImageSet = new HashSet <Texture>();
    }