Example #1
0
        /// <summary>
        /// 异步加载
        /// </summary>
        /// <param name="assetName"></param>
        public void LoadAsync(string assetName, AssetsLoadCallback callFun)
        {
            assetName = assetName.ToLower();

            AssetObject assetObj = GetAssetObj(assetName);

            var status = GetAssetObjStatus(assetName);

            if (assetObj == null || status == AssetObjStatus.None)
            {
                assetObj = new AssetObject()
                {
                    AssetName = assetName,
                };

                PutAssetObInDic(AssetObjStatus.Loading, assetObj);

#if UNITY_EDITOR && !AB_TEST
                assetObj.Asset = EditorAssetLoadMgr.LoadSync(assetName);
#else
                if (AssetBundleMgr.IsFileExist(assetName))
                {
                    assetObj.IsAbLoad = true;

                    AssetBundleMgr.LoadAsync(assetName, (ab) =>
                    {
                        if (GetAssetObjStatus(assetName) == AssetObjStatus.Loading && assetObj.Request == null && assetObj.Asset == null)
                        {
                            assetObj.Request = ab.LoadAssetAsync(ab.GetAllAssetNames()[0]);
                        }
                    });
                }
                else if (ResourcesLoadMgr.IsFileExist(assetName))
                {
                    assetObj.IsAbLoad = false;

                    assetObj.Request = ResourcesLoadMgr.LoadAsync(assetName);
                }
#endif
            }

            assetObj.CallbackList.Add(callFun);

            if (status == AssetObjStatus.Loaded)
            {
                loadedAsyncList.Add(assetObj);
            }
        }
Example #2
0
 public virtual void LoadSync(string assetName, AssetsLoadCallback callFun)
 {
     assetLoadMgr.LoadAsync(assetName, callFun);
 }