public IGameObject CreateGameObj(ref string strObjFileName, CreateGameObjectEvent callBack, object custumParam = null, TaskPriority ePriority = TaskPriority.TaskPriority_Normal, bool bCacheObj = true, bool bCacheForever = false)
        {
            List <IGameObject> objList = null;
            IGameObject        objNew  = null;

            if (bCacheObj)
            {
                if (m_mapRenderObjIdle.TryGetValue(strObjFileName, out objList)) // 缓存池里面有数据
                {
                    if (objList != null)
                    {
                        while (objList.Count > 0)
                        {
                            if (objList[0].GetGameObject() != null)
                            {
                                objNew = objList[0];
                                objList.RemoveAt(0);
                                objNew.SetCustomData(custumParam);
                                if (callBack != null)
                                {
                                    callBack(objNew, custumParam);
                                }
                                return(objNew);
                            }
                            else
                            {
                                objList.RemoveAt(0);
                            }
                        }
                    }
                }

                if (!m_lstCacheRenderObj.Contains(strObjFileName))
                {
                    m_lstCacheRenderObj.Add(strObjFileName);
                }
            }

            // 创建对象
            {
                GameObj obj = new GameObj();
                obj.CreateGameObject(ref strObjFileName, callBack, custumParam, ePriority);
                obj.bCacheForever = bCacheForever;
                objNew            = obj;

                objNew.SetCustomData(custumParam);
            }
            return(objNew);
        }
Exemple #2
0
 void LoadFinishDelegate(IResource res, string strResName, object customParam)
 {
     m_res = res as AssetBundleResource;
     if (m_res != null)
     {
         if (m_res.m_objRes == null && m_res.assetBundle != null)
         {
             Object[] objs = m_res.assetBundle.LoadAllAssets(typeof(UnityEngine.Object));
             if (objs != null && objs.Length > 0)
             {
                 m_res.m_objRes = objs[0];
             }
         }
         if (m_effect == null && m_res.m_objRes != null)
         {
             m_effect = GameObject.Instantiate(m_res.m_objRes) as GameObject;
             m_effect.transform.SetParent(m_node.transform);
             GameObj.RefreshShader(m_effect);
             m_node.name = m_effect.name.Replace("(Clone)", "");
             m_fDruation = CalcParticleSystemDuration(m_effect.transform);
         }
     }
 }