/// <summary> /// 创建对象池 /// </summary> /// <param name="poolName"></param> /// <param name="ts"></param> /// <returns></returns> private CMObjPool CreatePool( string poolName , Transform ts , bool needRelease = true , int preLoadNum = 0 , int maxHoldNum = 100 , bool cullNumEnable = true , int cullNum = 20 , int maxKeepWhenIdle = 20 , float maxIdle2Release = 120f , float maxActive2Idle = 60f , string addScriptName = "") { CMObjPool pool = null; if (!m_pools.TryGetValue(poolName, out pool)) { pool = CMObjPool.Create(poolName, ts, needRelease, preLoadNum, maxHoldNum, cullNumEnable , cullNum, maxKeepWhenIdle, maxIdle2Release, maxActive2Idle, m_poolRoot, true, addScriptName, CMResourceMgr.CM_RES_RECYCLE_TEST_MODE); m_pools.Add(poolName, pool); } else { CMObj cmObj = null; if (DataManager.Manager <CMResourceMgr>().TryGetCMObj(poolName, out cmObj)) { cmObj.RemoveRef(); } } return(pool); }
public static CombatManager CreateMyCM(Army attackers, Army defenders) { var thisObj = CMObj.AddComponent<CombatManager>(); //calls Start() on the object and initializes it. thisObj._attackers = attackers; thisObj._defenders = defenders; return thisObj; }
/// <summary> /// 获取游戏对象(同步) /// </summary> /// <param name="abPath"></param> /// <param name="assetName"></param> /// <returns></returns> public CMObj GetGameObj(string abPath, string assetName) { CMObj cmObj = null; if (!m_objs.TryGetValue(assetName, out cmObj)) { cmObj = new CMObj(abPath, assetName); m_objs.Add(assetName, cmObj); } return(cmObj.GetCMResource()); }
/// <summary> /// 获取游戏对象(异步) /// </summary> /// <param name="abPath"></param> /// <param name="assetName"></param> /// <param name="obj"></param> /// <param name="createDlg"></param> /// <param name="custParam"></param> /// <returns></returns> public bool GetGameObjAsyn(string abPath, string assetName, CMResEvent <CMObj> createDlg, object param1 = null, object param2 = null, object param3 = null) { CMObj cmObj = null; if (!m_objs.TryGetValue(assetName, out cmObj)) { cmObj = new CMObj(abPath, assetName); m_objs.Add(assetName, cmObj); } cmResAsynSeed = null; cmObj.GetCMResourceAsyn(ref cmResAsynSeed, createDlg, param1, param2, param3); return(true); }
/// <summary> /// 移除对象 /// </summary> /// <param name="poolName"></param> /// <returns></returns> public bool RemovePool(string poolName) { bool success = false; if (m_pools.Remove(poolName)) { CMObj cmObj = null; if (DataManager.Manager <CMResourceMgr>().TryGetCMObj(poolName, out cmObj)) { cmObj.RemoveRef(); } success = true; } return(success); }
public bool TryGetCMObj(string assetName, out CMObj cmObj) { return(m_objs.TryGetValue(assetName, out cmObj)); }