public void ExecuteCommand(int command, params object[] param) { List <OnCommand> commandList = null; if (commandDic.TryGetValue(command, out commandList)) { int count = commandList.Count; for (int i = 0; i < count; i++) { commandList[i](param); } } else { ZLog.Error("no command in " + ToString() + " named " + command); } }
protected void UnRegisteCommand(int command, OnCommand commandHandler) { List <OnCommand> commandList = null; if (commandDic.TryGetValue(command, out commandList)) { if (commandList.Contains(commandHandler)) { commandList.Remove(commandHandler); } else { ZLog.Error("no commandHandler with " + command + " named " + commandHandler.Method.Name); } } else { ZLog.Error("no command in " + ToString() + " named " + command); } }
public void UnloadAssetBundle(string bundlePath) { AssetBundle assetBundle = null; if (cacheAssetBundleDic.TryGetValue(bundlePath, out assetBundle)) { var dependences = manifest.GetAllDependencies(bundlePath); var count = dependences.Length; for (var i = count - 1; i >= 0; i--) { var dependence = dependences[i]; Unload(dependence); } Unload(bundlePath); } else { ZLog.Error($"No bundle cache named->{bundlePath}"); } }
public async Task <T> LoadAsset <T>(AssetId assetId) where T : Object { Object o = null; if (cacheResDic.TryGetValue(assetId, out o)) { return(o as T); } // #if UNITY_EDITOR // LoadAssetFromLocal<T>(assetId, onFinished); // #else AssetBundle bundle = null; T asset = null; try { if (cacheAssetBundleDic.TryGetValue(assetId.BundleId, out bundle)) { asset = await LoadAssetFromBundle <T>(assetId, bundle); } else { bundle = await LoadAssetBundle(assetId.BundleId); asset = await LoadAssetFromBundle <T>(assetId, bundle); } } catch (System.Exception e) { ZLog.Debug(e.Message + "=====" + e.StackTrace); } return(asset); //#endif }