public virtual AssetLoadHandler StartLoad(string path, AssetLoadCompleted callback = null) { var handler = GetOrCreateHandler(path); handler.OnCompleted(callback); //记录加载方式 if (callback == null) { handler.mode = AssetLoadMode.Async; } else { handler.mode = AssetLoadMode.Sync; } //等待队列里如果有依赖加载器,会引起主加载器没法完成,造成无限等待,所以依赖加载不能走这里 if (maxLoadingCount > 0 && LoadingCount >= maxLoadingCount) { handler.status = AssetLoadStatus.LOAD_WAIT; GetWaitQueue().AddLast(handler); } else { StartLoadWithHandler(handler); } return(handler); }
public void OnCompleted(AssetLoadCompleted callback = null) { if (callback != null) { onCallback += callback; } }
public int InstantiatePrefabAsync(string sPath, AssetLoadCompleted OnAssetLoadCompleted) { int iHandle = LoadAssetAsync <GameObject>(sPath, (ihandle, gameobject) => { GameObject go = GameObject.Instantiate(gameobject) as GameObject; m_PrefabMap.Add(go.GetInstanceID(), gameobject.GetInstanceID()); OnAssetLoadCompleted.Invoke(ihandle, go); }); return(iHandle); }
public AssetLoadHandler LoadAssetHandler <T>(string path, AssetLoadCompleted callback = null) where T : class { BaseLoader loader; string rightPath; SelectLoaderAndPath <T>(path, out loader, out rightPath); var handler = loader.StartLoad(rightPath, callback); return(handler); }
public void Reset() { id = 0; status = 0; result = null; loader = null; path = null; mode = AssetLoadMode.Async; onCallback = null; m_parents?.Clear(); m_children?.Clear(); m_callbackCount = 0; m_callbackCall = null; }
public int LoadAssetAsync <T>(string sPath, AssetLoadCompleted OnAssetLoadCompleted) where T : UnityEngine.Object { return(m_Loader.LoadAssetAsync <T>(sPath, OnAssetLoadCompleted)); }
public int LoadAssetAsync <T>(string sPath, AssetLoadCompleted OnAssetLoadCompleted) where T : UnityEngine.Object { AssetInfo <T> ai = AssetCacheMgr.Instance.GetAssetCache <T>(sPath, m_Loader); return(ai.LoadAsync(m_Loader, OnAssetLoadCompleted)); }