private void RemoveButton(ProviderModel providerData) { GUI.enabled = true; var btn = GUILayout.Button(new GUIContent { text = "Remove", }, buttonWidth, buttonHeight); if (btn && !isProcessing) { GUI.enabled = true; try { ZLog.Warning(">>>>>>>>> Remove Click! <<<<<<<<<<"); if (EditorUtility.DisplayDialog("Remove Package", "Are you sure you want to remove this package?", "Remove", "Cancle")) { ZBaseEditorCoroutines.StartEditorCoroutine(RemovePackage(providerData.providerName, (result) => { if (result.Status == StatusCode.Success) { ZLog.Info(string.Format("***Remove Success {0} {1}***", providerData.providerName, providerData.latestUnityVersion)); canRefresh = true; } })); } } catch (System.Exception e) { ZLog.Error("Error " + e.Message); } } }
private IZUIPanel CreatePanel(string uname, RectTransform parent) { ZUIPanel panel = null; for (int i = 0; i < prefabs.Count; i++) { ZUIPanel prefab = prefabs[i]; if (prefab != null) { panel = Instantiate(prefab); if (panel != null) { panel.name = prefab.name; panel.mTransform.SetParent(parent, false); panel.mTransform.localScale = Vector3.one; panel.effectPoint = effectPoint; panels.Add(panel); } else { ZLog.Warning("this is not ZUIPanel of these prefabs that is " + uname + "!!!"); } break; } } if (panel == null) { ZLog.Warning("can not find prefab that name = " + uname); } return(panel); }
public void SwitchLanguage(LanguageType type) { ZLog.Warning("LocalManager SwitchLanguage...from = " + language + " to " + type); if (language == type) return; language = type; TextAsset asset = null; if(type == LanguageType.Chinese){ asset = Resources.Load<TextAsset>("xml/chinese"); //LocalManager.currentFont = Font.CreateDynamicFontFromOSFont("Droid Sans Mono", 14); }else if(type == LanguageType.English){ asset = Resources.Load<TextAsset>("xml/english"); //LocalManager.currentFont = Font.CreateDynamicFontFromOSFont("Droid Sans Mono", 14); }else if(type == LanguageType.Japanese){ asset = Resources.Load<TextAsset>("xml/japanese"); proxy.Parse(asset.text); currentFont = Font.CreateDynamicFontFromOSFont("Noto Sans JP", 14); } else if (type == LanguageType.Korean) { asset = Resources.Load<TextAsset>("xml/korean"); } if (asset != null) { proxy.Parse(asset.text); NotifyManager.SendNotify(NotifyType.OnLaguageUpdate,null); } }
public T ActivateAsset <T>(uint assetid, Transform parent) where T : MonoBehaviour { AssetVarietyInfo info = GetVarietyInfo(assetid); if (info.id < 1) { ZLog.Warning("can not find variety asset info that id is " + assetid + " !!!!!"); return(null); } T prop = GetSleepAsset <T>(info.prefabName); if (prop == null) { T prefab = GetPrefab <T>(info.prefabBundle, info.prefabName, BundleType.Prefab_Mix); if (prefab == null) { return(null); } prop = CreateAsset <T>(prefab, info.prefabName); if (prop == null) { ZLog.Warning("can not create asset that name = " + typeof(T) + "!!!"); return(null); } } ResetAsset(prop.transform, parent); return(prop); }
private object GetObject(Type type, params object[] param) { lock (poolList) { for (int i = 0; i < poolCount; i++) { var poolData = poolList[i]; if (poolData.Obj.GetType() == type && !poolData.InUse) { poolData.InUse = true; if (poolData.Obj is IRecycleObject) { (poolData.Obj as IRecycleObject).Create(); } return(poolData.Obj); } } if (poolCount >= maxPoolCount && limitCount) { ZLog.Warning("object pool has max"); return(null); } object obj = ZInstanceUtility.CreateInstance(type, param); var newPoolData = new PoolData { InUse = true, Obj = obj }; poolList.Add(newPoolData); poolCount++; return(obj); } }
private IEnumerator LoadFromDisk(RequestInfo info) { isLoading = true; using (UnityWebRequest loader = UnityWebRequestTexture.GetTexture("file://" + info.url)) { loader.downloadHandler = new DownloadHandlerTexture(true); yield return(loader.SendWebRequest()); if (!string.IsNullOrEmpty(loader.error)) { ZLog.Warning("Image load error ....." + loader.error + ";url = " + info.url); } else { Texture2D tex = DownloadHandlerTexture.GetContent(loader); AddImage(tex.EncodeToJPG(), info, "", new Vector2(tex.width, tex.height)); } yield return(null); loader.Dispose(); } RemoveRequest(info.uid); isLoading = false; yield return(null); LoadNext(); }
private IEnumerator DownloadInspector(RequestInfo info, string path) { isLoading = true; UnityWebRequest loader = null; //ZLog.Warning("LoadInspector...." + info.url + "---"+info.screenIdx); using (loader = UnityWebRequestTexture.GetTexture(info.url)) { DownloadHandlerTexture texHandler = new DownloadHandlerTexture(true); loader.disposeDownloadHandlerOnDispose = true; loader.downloadHandler = texHandler; yield return(loader.SendWebRequest()); if (!string.IsNullOrEmpty(loader.error) || loader.isNetworkError || loader.isHttpError) { LoadFromApk(info.package); ZLog.Warning("Image load error ....." + loader.error); } else { //Texture2D tex = DownloadHandlerTexture.GetContent(loader); AddImage(texHandler.data, info, path, new Vector2(texHandler.texture.width, texHandler.texture.height)); } } RemoveRequest(info.uid); yield return(null); isLoading = false; loader.Dispose(); yield return(null); LoadNext(); }
public void Ready(string identify, string url, string path, long size, string name, UnityAction <Status, string, string> callfun, string md5 = "") { if (string.IsNullOrEmpty(url)) { ZLog.Warning("download url is empty!!!!that uid = " + identify); return; } string uid = GetUID(identify, size); RequestInfo info = GetRequest(uid); if (info == null) { RequestInfo request = new RequestInfo() { uid = uid, name = name, identify = identify, url = url, status = Status.Pending, size = size, path = path, md5 = md5, callback = callfun }; requests.Add(request); total += 1; } }
private void OnGraphDataUpdate(object data) { if (data == null) { return; } GraphModel graph = data as GraphModel; ZLog.Warning("create graph node = " + cacheNode + ";center = " + graph.Center + "; spawn = " + isSpawning); if (graph.Center != cacheNode || isSpawning) { return; } var success = DataManager.Instance.AddGraph(graph); if (success) { nowLevel += 1; layout.ExpendNode(graph.Center); StartCoroutine(CreateGraphInspector(graph)); } else { var node = layout.GetNode(graph.Center); if (node != null) { node.Expend = ExpendStatus.Disable; } } }
private string DealResponse(string json, out int st) { if (string.IsNullOrEmpty(json)) { st = (int)ServerErrorStaus.Unknown; DFNotifyManager.SendNotify(DFNotifyType.OnResponseError, ServerErrorStaus.Unknown); return(""); } //ZLog.Log("DealResponse...." + json.Length); try { var obj = LitJson.JsonMapper.ToObject(json); st = (int)obj["status"]; var status = (ServerErrorStaus)st; if (status == 0) { var data = obj["data"]; return(data.ToString()); } else { string msg = (string)obj["msg"]; ZLog.Warning("Server Response Exception...." + msg); DFNotifyManager.SendNotify(DFNotifyType.OnResponseError, status); return(""); } } catch (Exception e) { ZLog.Warning(e.Message); st = -1; return(""); } }
private ImageInfo AddImage(byte[] buffer, RequestInfo info, string path, Vector2 size) { if (buffer != null && size.x > 10 && size.y > 10) { //ZLog.Warning("generate texture bytes start...." + Time.realtimeSinceStartup); //byte[] buffer = tex.EncodeToPNG(); //ZLog.Warning("generate texture bytes end...." + Time.realtimeSinceStartup); if (!string.IsNullOrEmpty(path)) { ZFileManager.Instance.WriteFile(path, buffer); } Texture2D texture = CreateTexture(buffer, new Vector2(size.x, size.y)); ImageInfo detail = new ImageInfo(info.uid, info.identify, texture, info.url) { local = false }; loadedList.Add(detail); if (info.callFun != null) { info.callFun.Invoke(detail); } return(detail); } else { ZLog.Warning("texture is null..."); return(null); } }
public void RequestGraph(string uid, string parent) { if (isLocal) { var path = Path.Combine(rootPath, "graph/graph_" + uid + ".json"); if (!File.Exists(path)) { ZLog.Warning("the file not exist that path = " + path); DFNotifyManager.SendNotify(DFNotifyType.OnGraphDataUpdate, null); return; } var txt = File.ReadAllText(path); var graph = ParseUtil.ParseGraphJson(txt, rootPath); if (graph == null) { ZLog.Warning("the graph data is null"); DFNotifyManager.SendNotify(DFNotifyType.OnGraphDataUpdate, null); return; } graph.Parent = parent; DFNotifyManager.SendNotify(DFNotifyType.OnGraphDataUpdate, graph); } else { string address = GetAddress(HttpAPIType.Graph); var json = new LitJson.JsonData { ["uid"] = uid, ["parent"] = parent, ["code"] = codes }; ZHttpController.Post(URL_Graph, address, json.ToString(), HttpCompleteHandler, true); } }
public void RequestEntity(string uid) { if (isLocal) { var path = Path.Combine(rootPath, "entity/entity_" + uid + ".json"); if (!File.Exists(path)) { ZLog.Warning("the file not exist that path = " + path); return; } var txt = File.ReadAllText(path); var info = ParseUtil.ParseEntityJson(txt, rootPath); DFNotifyManager.SendNotify(DFNotifyType.OnEntityDataUpdate, info); } else { string address = GetAddress(HttpAPIType.Entity); LitJson.JsonData json = new LitJson.JsonData { ["uid"] = uid, ["code"] = codes }; ZHttpController.Post(URL_Entity, address, json.ToString(), HttpCompleteHandler, true); } }
private T CreatePanel <T>(RectTransform parent) where T : ZUIPanel { T panel = null; for (int i = 0; i < prefabs.Count; i++) { T prefab = prefabs[i] as T; if (prefab != null) { panel = Instantiate <T>(prefab); if (panel != null) { panel.name = typeof(T).Name; panel.mTransform.SetParent(parent, false); panel.mTransform.localScale = Vector3.one; panel.effectPoint = effectPoint; panels.Add(panel); } else { ZLog.Warning("this is not ZUIPanel of these prefabs that is " + typeof(T) + "!!!"); } break; } } if (panel == null) { ZLog.Warning("can not find prefab that name = " + typeof(T)); } return(panel); }
private void RequestException(HttpStateType type) { HttpInfo info; if (!string.IsNullOrEmpty(currentId)) { info = GetRequestByUID(currentId); } else { info = GetRequestByURL(currentReqURL); } if (info == null || (string.IsNullOrEmpty(info.uid) == false && callFuns.ContainsKey(info.funID))) { RemoveRequestInfo(info.uid); UnityAction <ResponseInfo> callfun = callFuns[info.funID]; if (callfun != null) { ResponseInfo response = new ResponseInfo(); response.state = type; response.data = "Request that code is " + info.uid + " and url = " + info.url + " is " + type + "!!!"; response.param = info.param; ZLog.Warning("RequestException....." + response.data); callfun.Invoke(response); } } else { RemoveRequestInfo(info.uid); } currentReqURL = ""; currentId = ""; isLoading = false; }
private void RequestException(Request info, Status type, string msg) { if (info != null) { if (info.callFun != null) { Response response = new Response { uid = info.uid, state = type, data = "Request that code is " + info.uid + " and url = " + info.url + " ;msg = " + msg + "!!!", param = info.param, }; ZLog.Warning("RequestException....." + response.data); info.callFun.Invoke(response); } } else { ZLog.Warning("RequestException.....HttpState = " + type + "---" + msg); } currentReqURL = ""; isLoading = false; }
public bool WriteFile(string path, byte[] bytes) { if (bytes == null) { return(false); } try { string dir = Path.GetDirectoryName(path); if (Directory.Exists(dir) == false) { Directory.CreateDirectory(dir); } if (File.Exists(path)) { File.Delete(path); } //File.WriteAllBytes(path, bytes); using (FileStream stream = new FileStream(path, FileMode.Create)) { stream.Write(bytes, 0, bytes.Length); stream.Flush(); stream.Close(); stream.Dispose(); } ZLog.Warning("write file success!!!!" + dir + "---" + path); return(true); } catch (Exception e) { ZLog.Exception(e); return(false); } }
void Start() { Init(); ZLog.Warning("relation graph simulator start...center = " + cacheNode); if (isStartEnd) { DataManager.Instance.GetGraphByNode(cacheNode); } }
private T CreateAsset <T>(T prefab, string path) where T : Component { if (prefab == null) { ZLog.Warning("can not create asset that path = " + path + "!!!"); return(null); } return(CreateAsset(prefab, prefab.name, path)); }
public static void ShowTip(string tip) { if (string.IsNullOrEmpty(tip)) { return; } ZLog.Warning(tip); AlertController.Instance.ShowAlert(null, tip, Vector2.zero); }
public void OpenNode(string uid, System.Action <string> fun) { cacheNode = uid; callAction = fun; ZLog.Warning("try open graph node..." + uid + ";" + isStartEnd); if (isStartEnd && isActiveAndEnabled) { DataManager.Instance.GetGraphByNode(uid); } }
private T LoadResource <T>(string path) where T : UnityEngine.Object { T prefab = Resources.Load <T>(path); if (prefab == null) { ZLog.Warning("can not find the prefab asset in local that path = " + path); return(null); } return(prefab); }
public Sprite GetSprite(uint assetid) { AssetVarietyInfo info = GetVarietyInfo(assetid); if (info.id < 1) { ZLog.Warning("Can not find variety asset info that id is " + assetid + " !!!!!"); return(null); } return(GetSprite(info.spriteBundle, info.spriteName, info.spriteType.ToString().ToLower())); }
private void OnEnable() { Init(); AddListeners(); ZLog.Warning("relation graph simulator enable...center = " + cacheNode); if (isStartEnd) { DataManager.Instance.GetGraphByNode(cacheNode); } pinchTool.ResetData(); }
private string GetString(string key, LanguageEnum type, params object[] args) { string val = GetString(key, type); if (val == null) { ZLog.Warning("can not find the key = " + key + " in local language!!!!"); return(""); } return(string.Format(val, args)); }
private void ReadImges(string path) { string[] files = Simulator.GetImagesInDirectory(path); if (files == null || files.Length < 1) { ZLog.Warning("look book...that directory is empty!!! path = " + path); return; } StartCoroutine(InitBookInspector(files)); }
public static string GetTextByPath(string path) { TextAsset asset = Resources.Load(path) as TextAsset; if (asset == null) { ZLog.Warning("Can not find config file that path = " + path + "!!!!"); return(""); } return(StringUtil.GetTextWithoutBOM(asset)); }
IEnumerator LoadMultyInspector(string identify, AudioLoad[] audios, bool loop, AudioType format) { int length = audios.Length; isLoading = true; AudioClip[] array = new AudioClip[length]; for (int i = 0; i < length; i++) { string uid = AlgorithmUtil.ToMD5(audios[i].path); AudioClip clip = GetClip(uid); if (clip == null) { using (var www = UnityWebRequestMultimedia.GetAudioClip("file://" + audios[i].path, format)) { yield return(www.SendWebRequest()); if (www.isNetworkError) { ZLog.Warning("load the music is empty!!!that path = " + www.error); NotifyManager.SendNotify(NotifyType.OnAudioLoadError, ""); yield break; } clip = DownloadHandlerAudioClip.GetContent(www); if (clip.length < 1) { ZLog.Warning("load the music is empty!!!that path = " + audios[i].path); NotifyManager.SendNotify(NotifyType.OnAudioLoadError, ""); yield break; } AudioInfo audioInfo = new AudioInfo { uid = uid, clip = clip }; clips.Add(audioInfo); array[i] = clip; } } else { array[i] = clip; yield return(null); } } for (int i = 0; i < length; i++) { ActiveMusic(array[i], audios[i].target, loop); } yield return(null); isLoading = false; NotifyManager.SendNotify(NotifyType.OnAudioPlay, identify); }
public static void WriteInt(AppPrefEnum key, int value) { try { PlayerPrefs.SetInt(GetProjectID(key.ToString()), value); PlayerPrefs.Save(); } catch (PlayerPrefsException e) { ZLog.Warning("can not save to pref!!!" + e.Message); } }
public static void WriteString(string key, string value) { try { PlayerPrefs.SetString(GetProjectID(key), value); PlayerPrefs.Save(); } catch (PlayerPrefsException e) { ZLog.Warning("can not save to pref!!!" + e.Message); } }