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 IEnumerator Update(BKAction onComplete = null) { this.onComplete = onComplete; var loader = LoaderMgr.Load(localVersionPath); loader.isCheckRedirectError = true; loader.onComplete += ld => { if (ld.hasError) { //TODO tip DoComplete(true); return; } localVersion = new VersionCfgMgr(); if (localVersion.Init(ld.text)) { LoadVersion(localVersion.versionAddr); } else { //TODO tip DoComplete(true); } }; while (!isComplete) { yield return(null); } }
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 int SetInterval(int frameInterval, BKAction action) { if (action == null) { return(0); } if (frameInterval <= 0) { action.Invoke(); frameInterval = 1; } while (intervals.ContainsKey(intervalId)) { intervalId++; if (intervalId == int.MaxValue) { intervalId = 1; } } intervals.Add(intervalId, new TickItem(frameInterval, action)); return(intervalId); }
IEnumerator DoGetAllResourcesAsync <T>(AssetBundle ab, BKAction <T[]> onComplete) where T : UnityEngine.Object { var req = ab.LoadAllAssetsAsync <T>(); yield return(req); onComplete((T[])req.allAssets); }
public static void RemoveMessageListener(uint opcode, BKAction <IMessage> messageHanlder) { BKEvent <IMessage> item; if (messages.TryGetValue(opcode, out item)) { item.RemoveListener(messageHanlder); } }
IEnumerator DoGetResourceAsync(IResourceFile file, AssetBundle ab, BKAction <UnityEngine.Object> onComplete) { var req = ab.LoadAssetAsync(file.idInPack, GetResourceType(file.type)); yield return(req); var obj = req.asset; BundleToAsset(file.srcFile, file, ab, obj); onComplete(obj); }
public static void AddMessageListener(uint opcode, BKAction <IMessage> messageHanlder) { BKEvent <IMessage> item; if (!messages.TryGetValue(opcode, out item)) { item = new BKEvent <IMessage>(); messages.Add(opcode, item); } item.AddListener(messageHanlder); }
IEnumerator DoGetResourceAsync <T>(IResourceFile file, AssetBundle ab, BKAction <T> onComplete) where T : UnityEngine.Object { var req = ab.LoadAssetAsync <T>(file.idInPack); yield return(req); var obj = (T)req.asset; BundleToAsset(file.srcFile, file, ab, obj); onComplete(obj); }
public void GetAllResourcesAsync <T>(int number, BKAction <T[]> onComplete) where T : UnityEngine.Object { var file = resourceTable.GetResourceFile(number); if (file != null) { GetAllResourcesAsync <T>(file.srcFile, onComplete); } else { onComplete(null); } }
public void GetResourceAsync(int number, BKAction <UnityEngine.Object> onComplete) { var file = resourceTable.GetResourceFile(number); if (file != null) { GetResourceAsync(file.srcFile, onComplete); } else { onComplete(null); } }
public void Invoke() { if (this.action != null) { this.action.Invoke(); } if (this.onceAction != null) { this.onceAction.Invoke(); this.onceAction = null; } }
public Loader Load(string path, BKAction <string> onComplete = null, bool cache = false) { var bReturn = false; if (string.IsNullOrEmpty(path)) { bReturn = true; Debug.LogWarning("LocalResMgr.load, path is empty"); } if (HasResource(path)) { bReturn = true; UpdateCache(path, cache); } if (bReturn) { if (onComplete != null) { onComplete(path); } return(null); } var file = resourceTable.GetResourceFile(path); var loader = file == null?LoaderMgr.Load(path) : LoaderMgr.Load(file.targetFile, file.version, file.size); loader.onComplete += ld => { if (!ld.hasError) { AddResource(path, ld.GetOrgAssetBundle(), cache); } if (onComplete != null) { onComplete(path); } ld.Dispose(); }; return(loader); }
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)); }
public static void GetResourceAsync <T>(int number, BKAction <T> onComplete) where T : UnityEngine.Object { impl.GetResourceAsync <T>(number, onComplete); }
public static void GetResourceAsync(int number, BKAction <UnityEngine.Object> onComplete) { impl.GetResourceAsync(number, onComplete); }
public static void GetAllResourcesAsync <T>(string path, BKAction <T[]> onComplete) where T : UnityEngine.Object { impl.GetAllResourcesAsync <T>(path, onComplete); }
public static void GetAllResourcesAsync(string path, BKAction <UnityEngine.Object[]> onComplete) { impl.GetAllResourcesAsync(path, onComplete); }
public static BatchLoader LoadBatch(ICollection <string> pathes, BKAction <ICollection <string> > onComplete = null, bool cache = false) { return(impl.LoadBatch(pathes, onComplete, cache)); }
public static BatchLoader LoadWithDependencies(string path, BKAction <string> onComplete = null, bool cache = false) { return(impl.LoadWithDependencies(path, onComplete, cache)); }
public static Loader Load(string path, BKAction <string> onComplete = null, bool cache = false) { return(impl.Load(path, onComplete, cache)); }
public override void RemoveAllListeners() { this.action = null; this.onceAction = null; }
/// <summary> /// remove event Listener, or BKEvent -= action /// </summary> public void RemoveListener(BKAction action) { this.action -= action; this.onceAction -= action; }
/// <summary> /// action will be removed after calling once /// </summary> public void AddOnceListener(BKAction action) { this.action += action; }
public TickItem(int frame, BKAction action) { this.frame = frame; this.action = action; last = 0f; }
public BatchLoader LoadWithDependencies(string path, BKAction <string> onComplete = null, bool cache = false) { if (HasResource(path)) { return(null); } var batch = LoaderMgr.LoadBatch(); var file = resourceTable.GetResourceFile(path); if (file == null) { batch.AddLoader(path); } else { if (file.dependencies != null) { foreach (var filestr in file.dependencies) { var file2 = resourceTable.GetResourceFile(filestr); if (!HasResource(file2)) { batch.AddLoader(file2.targetFile, file2.version, file2.size); } } } batch.AddLoader(file.targetFile, file.version, file.size); } if (batch.GetLoaders().Count == 0) { batch.DisposeImmediate(); if (onComplete != null) { onComplete(path); } return(null); } batch.onComplete += bt => { foreach (var item in bt.GetLoaders()) { if (!item.Value.hasError) { AddResource(item.Key, item.Value.GetOrgAssetBundle(), cache); } } if (onComplete != null) { onComplete(path); } bt.Dispose(); }; return(batch); }
public TickItem(float time, BKAction action) { this.time = time; this.action = action; last = Time.time; }