/// <summary> /// /// </summary> /// <param name="resID"></param> /// <param name="tsEvent"></param> /// <param name="param"></param> public void SpawnObjAsyn(uint resID, CMResEvent <Transform> tsEvent, object param1 = null, object param2 = null, object param3 = null) { table.UIResourceDataBase rsDb = GameTableManager.Instance.GetTableItem <table.UIResourceDataBase>(resID); if (null == rsDb) { if (null != tsEvent) { tsEvent.Invoke(null, param1, param2, param3); } return; } CMObjPool pool = null; if (m_pools.TryGetValue(rsDb.resRelativePath, out pool) && pool.State != CMObjPool.CMObjPoolState.Release) { if (null != tsEvent) { tsEvent.Invoke(pool.SpawnInstance(Vector3.zero, Quaternion.identity, true), param1, param2, param3); } } else { if (null != pool) { pool = null; RemovePool(rsDb.resRelativePath); } DataManager.Manager <CMResourceMgr>().GetGameObjAsyn(rsDb.assetbundlePath, rsDb.resRelativePath, (obj, passParam1, passParam2, passParam3) => { CMObjPool newpool = CreatePool( rsDb.resRelativePath , obj.GetGameObj().transform , rsDb.resKeepType != 2 , (int)rsDb.resPreloadNum , (int)rsDb.resCloneNumLimit , (rsDb.releaseCullAboveMask != 0) , (int)rsDb.releaseCullAboveNum , (int)rsDb.resIdleKeepNum , rsDb.idle2releaseTime , rsDb.active2idleTime , (rsDb.cloneAddScriptState == 1) ? rsDb.resName : ""); if (null != tsEvent) { tsEvent.Invoke(newpool.SpawnInstance(Vector3.zero, Quaternion.identity), passParam1, passParam2, passParam3); } }, param1, param2, param3); } }
/// <summary> /// 获取实例(同步) /// </summary> /// <param name="abPath"></param> /// <param name="assetName"></param> public Transform SpawnObj(uint resID, bool setActive = true) { table.UIResourceDataBase rsDb = GameTableManager.Instance.GetTableItem <table.UIResourceDataBase>(resID); if (null == rsDb) { return(null); } Transform ts = null; CMObjPool pool = null; if (m_pools.TryGetValue(rsDb.resRelativePath, out pool) && pool.State != CMObjPool.CMObjPoolState.Release) { ts = pool.SpawnInstance(Vector3.zero, Quaternion.identity, setActive); } else { if (null != pool) { RemovePool(rsDb.resRelativePath); } IUIGameObj ig = DataManager.Manager <CMResourceMgr>().GetGameObj(rsDb.assetbundlePath, rsDb.resRelativePath); if (null == ig.GetGameObj()) { Engine.Utility.Log.Error("ObjPoolManager->ig.GetGameObj() null, assetName:{0}", rsDb.resRelativePath); return(null); } CMObjPool newpool = CreatePool( rsDb.resRelativePath , ig.GetGameObj().transform , rsDb.resKeepType != 2 , (int)rsDb.resPreloadNum , (int)rsDb.resCloneNumLimit , (rsDb.releaseCullAboveMask != 0) , (int)rsDb.releaseCullAboveNum , (int)rsDb.resIdleKeepNum , rsDb.idle2releaseTime , rsDb.active2idleTime , ((rsDb.cloneAddScriptState == 1) ? rsDb.resName : "")); ts = newpool.SpawnInstance(Vector3.zero, Quaternion.identity, setActive); } return(ts); }