public override int LoadAsset(string rc, LoadAssetCallback callback, object userdata = null) { string path = GetNameWithoutExtension(rc); ResourceRequest rr = Resources.LoadAsync(path); rr.completed += (AsyncOperation ao) => { LoadResult lr = new LoadResult(); lr.isSuccess = ao.isDone; lr.assets = new UnityEngine.Object[1] { rr.asset }; lr.assetNames = new string[1] { rc }; lr.userData = userdata; if (ResourceCallBack != null) { ResourceCallBack.Invoke(lr); } if (callback != null) { callback.Invoke(lr); } }; // Resources 读取暂时一律按照1处理 return(1); }
protected IEnumerator DoGetAssetAsync(string assetName, LoadAssetCallback callback) { Object obj; if (_loadedAssets.TryGetValue(assetName, out obj)) { yield return(null); //隔一帧. } else { if (assetBundle != null) { var request = assetBundle.LoadAssetAsync(assetName); while (!request.isDone) { yield return(null); } obj = request.asset; if (obj != null) { PushLoadedAsset(assetName, obj); } } } if (callback != null) { callback.Invoke(obj); } }
public AssetBundleLoadAssetOperationFull(string bundleName, string assetName, System.Type type, LoadAssetCallback callback, object[] param) { m_AssetBundleName = bundleName; m_AssetName = assetName; m_Type = type; this.callback = callback; this.param = param; }
public void GetAssetAsync(string assetName, LoadAssetCallback callback) { if (_loadedAssets == null) { _loadedAssets = new Dictionary <string, Object>(); } // 这个MonoBehaviour类需要自己提供. AssetManager.instance.StartCoroutine(DoGetAssetAsync(assetName, callback)); }
public bool Cancel() { if (mStatus == TaskStatus.Running) { mStatus = TaskStatus.Canceled; onComplete = null; return(true); } return(false); }
public LoadAssetOperation LoadWindowWithResource(string resPath, LoadAssetCallback callback = null, ResourceLoadParam param = null) { if (string.IsNullOrEmpty(resPath)) { return(null); } if (ResContext.IsInProgress(resPath, string.Empty) != null) { return(null); } return(ResContext.LoadAssetAsync(resPath, "", typeof(GameObject), true, callback, param)); }
public override void LoadImagePack(string relativePath, LoadAssetCallback callback, LoadAssetCallback singleCallback, object userdata = null) { // TODO 暂时模拟Bundle肯定有卡顿,还没有好的解决方式 List <string> assetPaths = new List <string>(); UnityEngine.Object[] packs = Resources.LoadAll(relativePath); foreach (UnityEngine.Object pack in packs) { assetPaths.Add(relativePath + "/" + pack.name); } LoadAssets(assetPaths.ToArray(), callback, singleCallback, userdata); }
public UIManager() { m_UIGroup = new Dictionary<string, UIGroup>(); m_UIFormsBeingLoaded = new List<int>(); m_UIFormsToReleaseOnLoad = new HashSet<int>(); m_RecycleQueue = new LinkedList<IUIForm>(); m_LoadAssetCallback = new LoadAssetCallback(LoadUIFormSuccessCallback,..); m_ObjectPoolManager = null; m_ResourceManager = null; m_InstancePool = null; m_UIFormHelper = null; m_Serial = 0; m_OpenUIFormSuccessEventHandler = null; }
public void RemoveCallBack(string resourcesRelativePath, LoadAssetCallback callBack) { if (m_vResourceCallBackDic.ContainsKey(resourcesRelativePath)) { List <LoadAssetCallback> callBacks = m_vResourceCallBackDic[resourcesRelativePath]; if (callBacks != null && callBacks.Count > 0) { if (callBacks.Contains(callBack)) { callBacks.Remove(callBack); } } } }
public void SetupDatabasePath(LoadAssetCallback func) { if (IsOpen()) { if (func != null) { func(null, null); } return; } string root = "sdcard/db/QiuMo.bytes"; //string root = "C:/QiuMo.bytes"; if (File.Exists(root)) { Helper.Log("Get Database Success"); byte[] tembyte = File.ReadAllBytes(root); if (tembyte != null) { Open(tembyte); } if (func != null) { func(null, null); } return; } else { Helper.Log("File not exist!"); } string filePath = "{0}{1}"; Helper.Format(filePath, DATABASE_FILE_PATH, DATABASE_NAME); LoadAssetCallback tempCallback = delegate(UnityEngine.Object varObj, ResourceLoadParam varParam) { OnLoadDBFileFinsh(varObj, varParam); if (func != null) { func(varObj, varParam); } }; ResContext.LoadAssetAsync(filePath, DATABASE_NAME, typeof(TextAsset), tempCallback); }
public void OnLoadComplete(AssetBundle assetBundle) { if (mStatus != TaskStatus.Canceled) { mStatus = TaskStatus.Completed; if (onComplete != null) { onComplete.Invoke(assetBundle); } onComplete = null; } //else //{ // Debug.LogFormat("LoadAssetBundleTask OnLoadComplete but cancel"); //} }
private LoadOperation AnalysisEnvLevelOperation(string varBundleName, string varLevelName, LoadSceneMode varLoadSceneMode, LoadAssetCallback varCallBack) { LoadOperation tempResult = null; switch (ResConfig.CurLoadModel) { case ResourceMode.Resources: default: { tempResult = new ResourceLoadLevelOperation(varLoadSceneMode, varCallBack); } break; case ResourceMode.AssetBundle: { tempResult = new ABLoadLevelOperation(varLoadSceneMode, varCallBack); } break; #if EditorVersion case ResourceMode.AssetBundleSimulation: { tempResult = new SLABLoadLevelOperation(varLoadSceneMode, varCallBack); } break; #endif } return(tempResult); }
public void RegisterCallBack(string resourcesRelativePath, LoadAssetCallback callBack) { m_vResourceCallBackDic.ForceAddList(resourcesRelativePath, callBack); }
public int[] LoadAssets(string[] rc, int[] priorities, LoadAssetCallback callback, LoadAssetCallback sindleCallback = null, object userdata = null) { return(this.m_ResourceLoader.LoadAssets(rc, priorities, callback, sindleCallback, userdata)); }
public int LoadAsset(string relativePath, int priority, LoadAssetCallback callback, object userdata) { return(this.m_ResourceLoader.LoadAsset(relativePath, priority, callback, userdata)); }
/// <summary> /// 加载资源接口 /// </summary> /// <param name="rc"></param> /// <param name="callback"></param> /// <param name="userdata"></param> public int LoadAsset(string rc, LoadAssetCallback callback, object userdata = null) { return(this.m_ResourceLoader.LoadAsset(rc, callback, userdata)); }
public void LoadImagePack(string rc, LoadAssetCallback callback, LoadAssetCallback sindleCallback = null, object userdata = null) { this.m_ResourceLoader.LoadImagePack(rc, callback, sindleCallback, userdata); }
public static int[] LoadAssets(string[] relativePaths, int[] priorities, LoadAssetCallback callback, LoadAssetCallback singleCallback = null, object userdata = null) { return(ResourcesMgr.Instance.LoadAssets(relativePaths, priorities, callback, singleCallback, userdata)); }
public static int LoadAsset(string relativePath, int priority, LoadAssetCallback callback, object userdata = null) { return(ResourcesMgr.Instance.LoadAsset(relativePath, priority, callback, userdata)); }
public abstract int LoadAsset(string rc, int priority, LoadAssetCallback callback, object userdata = null);
public ResourceLoadLevelOperation(LoadSceneMode varLoadSceneMode, LoadAssetCallback varCallBack) { mLoadSceneMode = varLoadSceneMode; OperationCallback = varCallBack; }
private LoadOperation LoadAssetInternal <TAssetType, TParam>(string varBundleName, string varAssetName, bool varPriority, LoadAssetCallback <TAssetType> varCallBack, TParam varBackParam) where TAssetType : UnityEngine.Object { LoadOperation tempOperation = AnalysisEnvAssetOperation <TAssetType>(varBundleName, varAssetName, varCallBack); tempOperation.CallbackParam = new ResourceLoadParam <TParam>(varBundleName, varAssetName, varBackParam); if (varPriority) { AdvancedOperations.Add(tempOperation); } else { WaitingOperations.Add(tempOperation); } AutoPrepareEnv(); return(tempOperation); }
private LoadOperation AnalysisEnvAssetOperation <T>(string varBundleName, string varAssetName, LoadAssetCallback <T> varCallBack) where T : UnityEngine.Object { LoadOperation tempResult = null; switch (ResConfig.CurLoadModel) { case ResourceMode.Resources: default: { tempResult = new ResourceLoadAssetOperation <T>(varCallBack); } break; case ResourceMode.AssetBundle: { tempResult = new ABLoadAssetOperation <T>(varCallBack); } break; #if EditorVersion case ResourceMode.AssetBundleSimulation: { tempResult = new SLABLoadAssetOperation <T>(varCallBack); } break; #endif } return(tempResult); }
private LoadOperation LoadLevelInternal <TParam>(string varBundleName, string varLevelName, LoadSceneMode varLoadSceneMode, LoadAssetCallback varCallBack, TParam varBackParam) { LoadOperation tempOperation = AnalysisEnvLevelOperation(varBundleName, varLevelName, varLoadSceneMode, varCallBack); tempOperation.CallbackParam = new ResourceLoadParam <TParam>(varBundleName, varLevelName, varBackParam); //是否需要新建一个队列; WaitingOperations.Insert(0, tempOperation); AutoPrepareEnv(); return(tempOperation); }
public void LoadAsset(string assetBundleName, string assetName, System.Type type, LoadAssetCallback callback, params object[] param) { AssetBundleLoadAssetOperation operation = null; #if UNITY_EDITOR if (AssetLoader2.m_SimulateAssetBundleInEditor) { string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(assetBundleName, assetName); if (assetPaths.Length == 0) { Debug.LogError("There is no asset with name \"" + assetName + "\" in " + assetBundleName); callback(null, param); return; } // @TODO: Now we only get the main object from the first asset. Should consider type also. Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]); //operation = new AssetBundleLoadAssetOperationSimulation(target); callback(target, param); } else #endif { if (m_Manifest == null) { AddPendingLoad(assetBundleName); } else { LoadAssetBundle(assetBundleName); } operation = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, type, callback, param); operation.loader = this; m_InProgressOperations.Add(operation); } }
public ResourceLAssetAsyncOperation(LoadAssetCallback <TAssetType> varCallback) { OperationCallback = varCallback; }
public abstract void LoadImagePack(string relativePath, LoadAssetCallback callback, LoadAssetCallback singleCallback, object userdata = null);
/// <summary> /// 删除某资源的返回回调 /// </summary> /// <param name="resourcesRelativePath">AssetDatas下相对路径,例如"Prefabs/Hero/Hero1.prefab"</param> /// <param name="callBack"></param> public static void RemoveCallBack(string resourcesRelativePath, LoadAssetCallback callBack) { ResourcesMgr.Instance.RemoveCallBack(resourcesRelativePath, callBack); }
public abstract int[] LoadAssets(string[] rc, int[] priorities, LoadAssetCallback callback, LoadAssetCallback singleCallback, object userdata = null);
/// <summary> /// 读取相对文件夹路径下所有的文件 /// Resources(DEMO)方式读取时,可能有卡顿 /// </summary> /// <param name="relativePath">相对文件夹路径</param> /// <param name="callback"></param> /// <param name="singleCallback"></param> /// <param name="userdata"></param> public static void LoadImagePack(string relativePath, LoadAssetCallback callback, LoadAssetCallback singleCallback = null, object userdata = null) { ResourcesMgr.Instance.LoadImagePack(relativePath, callback, singleCallback, userdata); }