Ejemplo n.º 1
0
        protected virtual int UpdateCache(Sprite prev)
        {
            var prevCached = this.Cached;

            var ret = 0;

            if (this.selectedSprite)
            {
                if (-1 != (this.cacheIndex = this.FindCacheIndex(this.selectedSprite)))
                {
                    this.runtimeData = this.caches.GetCachedRuntimeData(this.cacheIndex);
                    ret = 1;
                }
                else
                {
                    this.runtimeData = SpriteRuntimeData.Shared.Regist(this.selectedSprite);
                    ret = 2;
                }
            }
            else
            {
                this.cacheIndex  = -1;
                this.runtimeData = null;
            }

            if (!prevCached)
            {
                SpriteRuntimeData.Shared.Unregist(prev);
            }

            return(ret);
        }
Ejemplo n.º 2
0
            public static SpriteRuntimeData Regist(Sprite sprite)
            {
                if (!sprite)
                {
                    return(null);
                }

                SpriteRuntimeData data;

                if (Shared.map.TryGetValue(sprite, out data))
                {
                    ++data.refCount;
                }
                else
                {
                    Shared.map.Add(sprite, data = new SpriteRuntimeData(sprite));
                }

                return(data);
            }