private IEnumerator LoadBundle(RelationNode node, LayerLoadParam param) { if (node.Nodes.Count() > 0) { LayerLoadParam layerParam = new LayerLoadParam(); layerParam.layer = param.layer + 1; layerParam.num = 0; for (int i = 0, count = node.Nodes.Count; i < count; i++) { CoroutineHelper.CreateCoroutineHelper(LoadBundle(node.Nodes[i], layerParam)); } while (layerParam.num >= 0 && layerParam.num < node.Nodes.Count) { yield return(null); } if (layerParam.num < 0) { UnLoad(); param.num = -100000; yield break; } } ResLoader.LoadByName(node.File, EndLoadBundle, new LoadInfo() { name = node.File, param = param }, true); }
public static void Ping(string ip, LuaInterface.LuaFunction func, int funcID) { if (func == null) { return; } NetPing ping = GenPing(); if (ping == null) { Debug.LogError("ping num is to much"); return; } if (Config.Detail_Debug_Log()) { Debug.Log("----------net ping 0->" + ip); } CoroutineHelper.CreateCoroutineHelper(ping.PingConnect(ip, (state, delay) => { ping.index = -1; LuaManager.CallFunc_V(func, state, delay, funcID); })); }
private void EndReadBytes(byte[] data, object obj) { if (data == null) { SetOver(); return; } MemoryStream ms = new MemoryStream(data); relationFile = RelationFile.Deserialize(ms); if (relationFile != null) { CoroutineHelper.CreateCoroutineHelper(LoadAsset(relationFile)); } else { SetOver(); } }
public static void Ping(string ip, NetPingCallBack callback) { if (callback == null) { return; } NetPing ping = GenPing(); if (ping == null) { Debug.LogError("ping num is to much"); return; } CoroutineHelper.CreateCoroutineHelper(ping.PingConnect(ip, (state, delay) => { ping.index = -1; callback(state, delay); })); }
private IEnumerator LoadAsset(RelationFile rf) { if (rf.Nodes.Count == 0) { SetOver(); yield break; } var node = rf.Nodes[0]; if (node.Nodes.Count() > 0) { LayerLoadParam layerParam = new LayerLoadParam(); layerParam.layer = 0; layerParam.num = 0; for (int i = 0, count = node.Nodes.Count; i < count; i++) { CoroutineHelper.CreateCoroutineHelper(LoadBundle(node.Nodes[i], layerParam)); } while (layerParam.num >= 0 && layerParam.num < node.Nodes.Count()) { yield return(null); } if (layerParam.num < 0) { UnLoad(); SetOver(); yield break; } } ResLoader.LoadByName(node.File, EndLoadAsset, new LoadInfo() { name = node.File, param = null }); }
private void CreateAssetBundle(string originName, string destName, string path, Example.VersionFile.Type fileType, Request request, EndLoadBundle endLoad, System.Object ud, bool assetBundle)//, bool cb_whatever) { if (fileType == Example.VersionFile.Type.DEFAULT) { CoroutineHelper.CreateCoroutineHelper(CreateAssetBundle_Offset(originName, path, 0, request, endLoad, ud, assetBundle)); } else if (fileType == Example.VersionFile.Type.COMBINE_FILE) { CombineFile cf = CombineFileManager.GetInstance().GetCombineFile(destName); int offset; int size; bool encrypt; cf.GetFileDetail(originName, out offset, out size, out encrypt); if (encrypt) { Debugger.LogError("asset bundle resource in combine file should not encrypt"); return; } CoroutineHelper.CreateCoroutineHelper(CreateAssetBundle_Offset(originName, path, (ulong)offset, request, endLoad, ud, assetBundle)); } }
private IEnumerator CreateAssetBundle_Offset(string name, string path, ulong offset, Request request, EndLoadBundle endLoad, System.Object ud, bool assetBundle)//, bool cb_whatever) { if (Config.Detail_Debug_Log()) { Debug.LogWarning("begin create asset ---------->" + name); } AssetBundleCreateRequest result = AssetBundle.LoadFromFileAsync(path, 0, offset); yield return(result); if (Config.Detail_Debug_Log()) { Debug.LogWarning("end create asset ----------->" + name); } if (!result.isDone || result.assetBundle == null) { if (Config.Debug_Log()) { Debugger.LogError("Failed to create asset bundle: " + path + "^" + ResUpdate.ConvertPathToName(path)); } cache.Remove(name); ProcessRequest(request, (System.Object)endLoad, ud); yield break; } if (!assetBundle) { request.asset = result.assetBundle.mainAsset; if (Config.Detail_Debug_Log()) { if (result.assetBundle.mainAsset != null) { Debug.LogWarning("create asset bundle type->" + result.assetBundle.mainAsset); } } } else { request.asset = result.assetBundle; } if (request.asset == null) { UnityEngine.Object[] arr = result.assetBundle.LoadAllAssets(); if (arr != null && arr.Length > 0) { request.asset = arr[0]; if (arr.Length > 1) { for (int i = 1, count = arr.Length; i < count; i++) { Resources.UnloadAsset(arr[i]); } } } } if (request.asset == null) { if (Config.Debug_Log()) { Debugger.LogError("Failed to load asset:%s, asset is null", ResUpdate.ConvertPathToName(path)); } } request.referenceNum++; ProcessRequest(request, (System.Object)endLoad, ud); if (!assetBundle) { CoroutineHelper.CreateCoroutineHelper(AsynUnloadAssetBundle(result.assetBundle)); } }
public void LoadBundle(string originName, string destName, string path, Example.VersionFile.Type fileType, EndLoadBundle endLoad, System.Object endLoadParam, bool assetBundle = false)//, bool cb_whatever = false) { if (path == null || path == "") { return; } Request request; if (!cache.TryGetValue(originName, out request)) { request = new Request(); cache.Add(originName, request); if (fileType == Example.VersionFile.Type.RELATION_FILE) { CoroutineHelper.CreateCoroutineHelper(CreateAssetBundle_RelationFile(originName, destName, request, endLoad, endLoadParam)); } else { CreateAssetBundle(originName, destName, path, fileType, request, endLoad, endLoadParam, assetBundle); } } else { if (request.referenceNum < 0) { if (Config.Debug_Log()) { Debugger.LogError("referencenum is invalid->" + request.referenceNum); } request.referenceNum = 0; } request.referenceNum++; if (fileType == Example.VersionFile.Type.RELATION_FILE) { if (request.raf.GetMainAsset() == null) { PushOP(request, endLoad, endLoadParam); } else { if (endLoad != null) { endLoad(request.raf.GetMainAsset(), endLoadParam); } } } else { if (request.asset == null) { PushOP(request, (System.Object)endLoad, endLoadParam); } else { if (endLoad != null) { endLoad(request.asset, endLoadParam); } } } } }