Example #1
0
 //数据重置
 public void Reset()
 {
     m_onAsyncLoadFinished       = null;
     m_onAsyncLoadObjectFinished = null;
     m_resourceObjectItem        = null;
     m_parms = null;
 }
Example #2
0
 public void Reset()
 {
     m_crc                       = 0;
     m_cloneObeject              = null;
     m_isClear                   = true;
     m_instanceId                = 0;
     m_isAlreadyRelease          = false;
     m_isSetToDefault            = false;
     m_onAsyncLoadObjectFinished = null;
     m_parms                     = null;
     m_asyncGuid                 = 0;
     m_resOffLineData            = null;
 }
Example #3
0
        /// <summary>
        /// 异步加载需要实力化的GameObject的函数
        /// </summary>
        /// <param name="resPath"></param>
        /// <param name="onAsyncLoadFinished"></param>
        /// <param name="loadResPriority"></param>
        /// <param name="isSetToDefault"></param>
        /// <param name="parms"></param>
        /// <param name="isChangeSceneClear"></param>
        public long InstantiateGameObejectAsync(string resPath, OnAsyncLoadObjectFinished onAsyncLoadFinished, LoadResPriority loadResPriority,
                                                bool isSetToDefault = false, object[] parms = null, bool isChangeSceneClear = true)
        {
            if (string.IsNullOrEmpty(resPath))
            {
                return(0);
            }

            uint crc = MCrcHelper.GetCRC32(resPath);
            MResourceObjectItem mResourceObjectItem = GetObjectFromPool(crc);

            if (mResourceObjectItem != null && mResourceObjectItem.m_cloneObeject != null)
            {
                if (isSetToDefault)
                {
                    mResourceObjectItem.m_cloneObeject.transform.SetParent(DefaultObjectTrans);
                }

                if (onAsyncLoadFinished != null)
                {
                    onAsyncLoadFinished(resPath, mResourceObjectItem, parms);
                }
                return(mResourceObjectItem.m_asyncGuid);
            }
            long m_asyncGuid = MResourceManager.singleton.GetGUID();

            mResourceObjectItem                             = m_resourceObjectClssPool.Spawn(true);
            mResourceObjectItem.m_crc                       = crc;
            mResourceObjectItem.m_isSetToDefault            = isSetToDefault;
            mResourceObjectItem.m_isClear                   = isChangeSceneClear;
            mResourceObjectItem.m_onAsyncLoadObjectFinished = onAsyncLoadFinished;
            mResourceObjectItem.m_parms                     = parms;
            mResourceObjectItem.m_asyncGuid                 = m_asyncGuid;

            //添加到异步加载管理列表里
            m_asyncResourcesObjectsDic.Add(m_asyncGuid, mResourceObjectItem);
            //调用MResourceManager为Object准备的的异步加载函数
            MResourceManager.singleton.AsyncLoadResource(resPath, mResourceObjectItem, OnAsyncLoadObjectFinish, loadResPriority, parms);
            return(m_asyncGuid);
        }
Example #4
0
        /// <summary>
        /// 实例化资源异步加载 为MObjectManager提供的接口
        /// </summary>
        /// <param name="resPath">资源路径</param>
        /// <param name="mResourceObjectItem"></param>
        /// <param name="onAsyncLoadObjectFinished">加载回掉</param>
        /// <param name="loadResPriority">优先级</param>
        /// <param name="parms"></param>
        public void AsyncLoadResource(string resPath, MResourceObjectItem mResourceObjectItem, OnAsyncLoadObjectFinished onAsyncLoadObjectFinished, LoadResPriority loadResPriority, object[] parms = null)
        {
            if (string.IsNullOrEmpty(resPath))
            {
                return;
            }

            MResourceItem mResourceItem = GetCacheResourceItem(mResourceObjectItem.m_crc);

            if (mResourceItem != null && mResourceItem.m_object != null)
            {
                if (onAsyncLoadObjectFinished != null)
                {
                    onAsyncLoadObjectFinished(resPath, mResourceObjectItem, parms);
                }
                return;
            }

            //判断下对象是不是在加载中
            AsyncLoadResParam asyncLoadResParam = null;

            if (!m_asyncLoadingAssetDic.TryGetValue(mResourceObjectItem.m_crc, out asyncLoadResParam) || asyncLoadResParam == null)
            {
                asyncLoadResParam                   = m_asyncLoadResParamPool.Spawn(true);
                asyncLoadResParam.m_crc             = mResourceObjectItem.m_crc;
                asyncLoadResParam.m_resPath         = resPath;
                asyncLoadResParam.m_loadResPriority = loadResPriority;
                //结果保存
                m_asyncAssetLoadingList[(int)loadResPriority].Add(asyncLoadResParam);
                m_asyncLoadingAssetDic.Add(mResourceObjectItem.m_crc, asyncLoadResParam);
            }

            //添加回调
            AsyncCallBack m_asyncCallBack = m_asyncCallBackPool.Spawn(true);

            m_asyncCallBack.m_onAsyncLoadObjectFinished = onAsyncLoadObjectFinished;
            m_asyncCallBack.m_resourceObjectItem        = mResourceObjectItem;
            asyncLoadResParam.m_asyncCallBacks.Add(m_asyncCallBack);
        }