Exemple #1
0
 /// <summary>
 /// 预加载
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="resType"></param>
 /// <param name="assetPath"></param>
 /// <param name="count"></param>
 /// <param name="clear"></param>
 public void PreLoadObj <T>(ResFromType resType, string assetPath, int count = 1, bool clear = false) where T : Object
 {
     if (CheckNoCanLoad())
     {
         AFLogger.e("此Loader已经被释放,请注意!");
         return;
     }
     for (int i = 0; i < count; i++)
     {
         ObjLoadInfo objLoadInfo = ObjLoadInfo.Allocate(resType, assetPath, null, false);
         ResManager.Instance.PreLoadObj(objLoadInfo);
         objLoadInfo.Recycle2Cache();
     }
 }
Exemple #2
0
        /// <summary>
        /// 同步加载Prefab,返回其实例化的GameObject
        /// </summary>
        /// <param name="resType"></param>
        /// <param name="assetPath"></param>
        /// <param name="parTrans"></param>
        /// <param name="bClear"></param>
        /// <returns></returns>
        public GameObject InstantiateObjectSync(ResFromType resType, string assetPath, Transform parTrans = null, bool bClear = true)
        {
            if (CheckNoCanLoad())
            {
                AFLogger.e("此Loader已经被释放,请注意!");
                return(null);
            }
            ObjLoadInfo objLoadInfo = ObjLoadInfo.Allocate(resType, assetPath, parTrans, bClear);
            GameObject  objAsset    = ResManager.Instance.InstantiateObjectSync(objLoadInfo);

            if (objAsset != null)
            {
                //加载完成后添加到加载资源列表中
                mObjList.AddValue(objAsset.GetInstanceID());
            }
            objLoadInfo.Recycle2Cache();
            return(objAsset);
        }
Exemple #3
0
        /// <summary>
        /// 异步加载Object
        /// </summary>
        /// <param name="objLoadInfo"></param>
        public static void InstantiateObjectASync(ObjLoadInfo objLoadInfo)
        {
            //从对象池拿取对象
            ResObject resObject = ResManager.Instance.GetObjectFromPool(objLoadInfo.mCRC);

            if (resObject == null)
            {
                //ResourceLoader加载资源
                ResourceLoader.Instance.LoadResAsyncForObj(objLoadInfo);
            }
            else
            {
                if (objLoadInfo.ObjParentTrans != null)
                {
                    resObject.mCloneObj.transform.SetParent(objLoadInfo.ObjParentTrans);
                }
                objLoadInfo.loadObjCall(true, resObject);
                objLoadInfo.Recycle2Cache();
            }
        }