Exemplo n.º 1
0
 public void PurgeCategory(string cat)
 {
     if (cached.ContainsKey (cat)) {
         cached[cat] = new GameObjectStore();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds gameObject to cache.
        /// Cached gameObjects won't be destroyed by loading a new scene, clear this cache manually if needed.
        /// </summary>
        /// <param name="category">Category.</param>
        /// <param name="item">Item.</param>
        void AddToCache(string category, GameObject item)
        {
            ICacheable cch = item.GetComponent<ICacheable>();

            if (cch != null) {
                LevelController.OnBeforeLevelLoad += cch.HandleOnBeforeLevelLoad;
            }

            GameObjectStore store;
            if (!cached.ContainsKey(category))
            {
                store = new GameObjectStore();
            }
            else
                store = cached[category];

            store.Add(item);
            // we re-add here, in case we entered the first case and a new store has been created
            cached[category] = store;
        }