Esempio n. 1
0
        public ReusablePrefab Instantiate(ReusablePrefab prefab, Vector3 position, Quaternion rotation)
        {
            if (!this._prefabDict.ContainsKey(prefab))
            {
                this._prefabDict[prefab] = new PrefabCache.ReusablePrefabContainer(prefab);
            }
            ReusablePrefab prefab2 = this._prefabDict[prefab].GetPrefab(position, rotation);

            prefab2.Restart();
            return(prefab2);
        }
Esempio n. 2
0
            public ReusablePrefab GetPrefab(Vector3 position, Quaternion rotation)
            {
                if (this._availablePrefabs.Count > 0)
                {
                    ReusablePrefab reusablePrefab = this._availablePrefabs.Pop();
                    reusablePrefab.transform.position = position;
                    reusablePrefab.transform.rotation = rotation;
                    return(reusablePrefab);
                }
                ReusablePrefab component = (UnityEngine.Object.Instantiate(this._prefab.TransRef, position, rotation) as Transform).GetComponent <ReusablePrefab>();

                component.PrefabDeactivated += new PrefabDeactivatedEventHandler(this.ReusablePrefabDeactivatedEventHandler);
                return(component);
            }
Esempio n. 3
0
 public ReusablePrefab Instantiate(ReusablePrefab prefab, Vector3 position)
 {
     return(this.Instantiate(prefab, position, default(Quaternion)));
 }
Esempio n. 4
0
 public ReusablePrefab Instantiate(ReusablePrefab prefab)
 {
     return(this.Instantiate(prefab, Vector3.zero));
 }
Esempio n. 5
0
 private void ReusablePrefabDeactivatedEventHandler(ReusablePrefab prefab)
 {
     this._availablePrefabs.Push(prefab);
 }
Esempio n. 6
0
 public ReusablePrefabContainer(ReusablePrefab prefabReference)
 {
     this._prefab           = prefabReference;
     this._availablePrefabs = new Stack <ReusablePrefab>();
 }