Пример #1
0
        public void GetAllAssetInResources()
        {
            var assets = Resources.FindObjectsOfTypeAll <A>();

            foreach (var asset in assets)
            {
                if (assetDict.ContainsKey(asset.GetInstanceID()) == false)
                {
                    assetDict.Add(asset.GetInstanceID(), asset);
                }
            }

            assets = Resources.LoadAll <A>("");
            foreach (var asset in assets)
            {
                if (assetDict.ContainsKey(asset.GetInstanceID()) == false)
                {
                    assetDict.Add(asset.GetInstanceID(), asset);
                }
            }

            foreach (var asset in assetDict.Values)
            {
                ObjectKun.AddCache(asset);
            }
        }
Пример #2
0
        public override bool WriteBack(Component component)
        {
            base.WriteBack(component);

            var spriteRenderer = component as SpriteRenderer;

            if (spriteRenderer)
            {
                if (spriteRenderer.sprite == null ||
                    spriteRenderer.sprite.GetInstanceID() != sprite.GetInstanceID())
                {
                    var tmp = ObjectKun.GetCache(sprite.instanceID) as Sprite;
                    if (tmp != null)
                    {
                        spriteRenderer.sprite = tmp;
                    }
                }
                spriteRenderer.color           = color.GetColor();
                spriteRenderer.flipX           = flipX;
                spriteRenderer.flipY           = flipY;
                spriteRenderer.drawMode        = drawMode;
                spriteRenderer.maskInteraction = maskInteraction;
                spriteRenderer.spriteSortPoint = spriteSortPoint;
                return(true);
            }

            return(false);
        }