/* * public void PrepareGameObject(string prefabFullPath, enResourceType resourceType, int amount, Action OnFinish) * { * string prefabFullPathInRes = CFileManager.EraseExtension(prefabFullPath); * Queue<CPooledGameObjectScript> queue = null; * if (!this._pooledGameObjectMap.TryGetValue(prefabFullPathInRes.JavaHashCodeIgnoreCase(), out queue)) * { * queue = new Queue<CPooledGameObjectScript>(); * this._pooledGameObjectMap.Add(prefabFullPathInRes.JavaHashCodeIgnoreCase(), queue); * } * if (queue.Count >= amount) * { * OnFinish(); * return; * } * amount -= queue.Count; * _mono.StartCoroutine(Precache(amount, prefabFullPath, resourceType, prefabFullPathInRes, queue, OnFinish)); * return; * }*/ /* * public System.Collections.IEnumerator Precache(int amount, string prefabFullPath, CustomAsyncOperation customAsyncOperation) * { * if (customAsyncOperation != null) * customAsyncOperation.AddMission(); * * Queue<CPooledGameObjectScript> queue = null; * * if (!this._pooledGameObjectMap.TryGetValue(prefabFullPath, out queue)) * { * queue = new Queue<CPooledGameObjectScript>(); * this._pooledGameObjectMap.Add(prefabFullPath, queue); * } * * var co = ResourceManager.Instance.GetResourceAsync(prefabFullPath, typeof(GameObject), resourceType); * while (co.MoveNext()) * { * yield return co.Current; * } * * for (int i = 0; i < amount; i++) * { * CPooledGameObjectScript cPooledGameObjectScript = this.CreateGameObject(prefabFullPath, Vector3.zero, Quaternion.identity); * * SuperDebug.Assert(cPooledGameObjectScript != null, "Failed Create Game object from \"{0}\"", new object[] * { * prefabFullPath * }); * * if (cPooledGameObjectScript != null) * { * queue.Enqueue(cPooledGameObjectScript); * cPooledGameObjectScript.gameObject.transform.SetParent(this.m_poolRoot.transform, true); * cPooledGameObjectScript.OnPrepare(); * } * } * if (customAsyncOperation != null) * customAsyncOperation.FinishMission(); * }*/ private CPooledGameObjectScript CreateGameObject(string prefabFullPath, Vector3 pos, Quaternion rot, bool useRotation) { GameObject prefabObj = Resources.Load <GameObject>(prefabFullPath); if (prefabObj == null) { SuperDebug.Error("prefabObj Can Not Be Null " + prefabFullPath); return(null); } GameObject instObj; if (useRotation) { instObj = (GameObject.Instantiate(prefabObj, pos, rot) as GameObject); } else { instObj = (GameObject.Instantiate(prefabObj) as GameObject); instObj.transform.position = pos; } SuperDebug.Assert(instObj != null); CPooledGameObjectScript cPooledGameObjectScript = instObj.GetComponent <CPooledGameObjectScript>(); if (cPooledGameObjectScript == null) { cPooledGameObjectScript = instObj.AddComponent <CPooledGameObjectScript>(); } cPooledGameObjectScript.Initialize(prefabFullPath); cPooledGameObjectScript.OnCreate(); return(cPooledGameObjectScript); }
public void AddEventListener <T>(T1 eventId, Action <T> handle) { Delegate d = null; if (!_dictEvent.TryGetValue(eventId, out d)) { _dictEvent.Add(eventId, handle); } else { if (d is Action <T> ) { _dictEvent[eventId] = (Action <T>)d + handle; } else { SuperDebug.Error("event id is " + eventId + " d is " + d.Method + " not match "); foreach (var item in d.GetInvocationList()) { SuperDebug.Error("d invocation is " + item.Method); } } } }