public void GetResourceAsync(string path, BKAction <UnityEngine.Object> onComplete) { if (assetList.ContainsKey(path)) { onComplete((assetList[path].RefTarget() as UnityEngine.Object)); return; } var ab = GetAssetBundle(path); if (ab == null) { onComplete(null); return; } IResourceFile file = resourceTable.GetResourceFile(path); if (file == null) { BundleToAsset(path, file, ab, ab); onComplete(ab); return; } CoroutineMgr.StartCoroutine(DoGetResourceAsync(file, ab, onComplete)); }
public void GetResourceAsync <T>(string path, BKAction <T> onComplete) where T : UnityEngine.Object { if (assetList.ContainsKey(path)) { onComplete((T)(assetList[path].RefTarget())); return; } var ab = GetAssetBundle(path); if (ab == null) { onComplete(default(T)); return; } IResourceFile file = resourceTable.GetResourceFile(path); if (file == null) { BundleToAsset(path, file, ab, ab); onComplete((T)Convert.ChangeType(ab, typeof(T))); return; } CoroutineMgr.StartCoroutine(DoGetResourceAsync <T>(file, ab, onComplete)); }
public static void Test() { TestWWW test = new TestWWW(); CoroutineMgr coroutineMgr = new CoroutineMgr(); coroutineMgr.StartCoroutine(test.TestWWWCoroutine()); while (true) { coroutineMgr.Update(); Thread.Sleep(33); } }
public virtual void Load(bool useCache = true, bool useBackupUrl = false) { #if RES_EDITOR gameObject = AssetDatabase.LoadMainAssetAtPath("Assets/" + url) as GameObject; #else if (isComplete || www != null || assetBundle != null) { throw new InvalidOperationException("Don't reuse Loader"); } this.useCache = useCache; if (startTime == 0f) { startTime = Time.time; } lastProgressTime = Time.time; lastProgress = 0f; isComplete = false; string strUrl; if (useBackupUrl) { strUrl = GetActualUrl(url, backupBaseUrl); if (!string.IsNullOrEmpty(baseUrl) && !string.IsNullOrEmpty(backupBaseUrl) && strUrl.Contains(baseUrl)) { strUrl = strUrl.Replace(baseUrl, backupBaseUrl); } } else { strUrl = GetActualUrl(url, baseUrl); } actualUrl = strUrl; Log.Debug(logTag, string.Format("{4} load from {0}: {1}, version: {2}, useCache: {3}", useBackupUrl ? "backup url" : "url", strUrl, version, useCache, retryCount > 0 ? retryCount.ToString() + "st retry" : "Start")); CoroutineMgr.StartCoroutine(DoLoad(strUrl)); #endif }
public void GetAllResourcesAsync <T>(string path, BKAction <T[]> onComplete) where T : UnityEngine.Object { IResourceFile file = resourceTable.GetResourceFile(path); if (file != null && file.singleDirectResource && assetList.ContainsKey(file.srcFile)) { onComplete(new T[] { (T)assetList[file.srcFile].RefTarget() }); return; } var ab = GetAssetBundle(path); if (ab == null) { return; } CoroutineMgr.StartCoroutine(DoGetAllResourcesAsync <T>(ab, onComplete)); }