public void dispose(GameObject target) { if (target == null) { Debug.LogWarning("Dispos target == null"); return; } int count = 0; int id = target.GetInstanceID(); foreach (BumPoolData item in poolDic.Values) { if (item.type == BumPoolDataType.eBumPoolDataType_texture2D) { BumPoolTextureData textureData = item as BumPoolTextureData; if (textureData.remove(id)) { count++; //texture是引用不能销毁物体 如需销毁在外部自己做此处不应提供if (target != null) GameObject.Destroy(target); } } if (item.type == BumPoolDataType.eBumPoolDataType_prefab) { BumPoolPrefabData prefabData = item as BumPoolPrefabData; if (prefabData.remove(id)) { count++; //只有prefab实例会销毁 if (target != null) { GameObject.Destroy(target); } } } } //foreach (LoadPoolData item in pool.Values) //{ // if (item.type == PoolDataType.Prefab) // { // PrefabData prefabData = item as PrefabData; // prefabData.Remove(id); // count++; // 只有prefab实例会销毁 // GameObject.Destroy(target); // } //} if (count == 0) { Debug.LogWarning("Dispos未找到" + target.name); } }
public BumPoolPrefabData addPrefab(string keyUrl, object resource, bool DonnotClear = false) { if (poolDic.ContainsKey(keyUrl)) { if (poolDic[keyUrl] is BumPoolErrorData) { poolDic.Remove(keyUrl); Debug.Log(" "); } else { Debug.Log("重复添加" + keyUrl); return(poolDic[keyUrl] as BumPoolPrefabData); } } BumPoolPrefabData prefabLoadData = new BumPoolPrefabData(keyUrl, resource, DonnotClear); poolDic.Add(keyUrl, prefabLoadData); return(prefabLoadData); }