IEnumerator UpdateAttachment(AttachmentsConfig config, string attachment_id) { var dict = new Dictionary <string, string>(); dict["id"] = config.id + ""; dict["itemType"] = "Skin"; dict["itemId"] = config.itemId; dict["name"] = config.name; dict["attachmentId"] = attachment_id; var argu = QF.SerializeHelper.ToJson <Dictionary <string, string> >(dict); var webRequest = UnityWebRequest.Put("https://gate.mongomath.com:8443/admin-course/item/attachment/" + config.id, argu); webRequest.SetRequestHeader("Authorization", Auth); webRequest.SetRequestHeader("Content-Type", "application/json"); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); } else { Debug.Log(webRequest.downloadHandler.text); var ret = QF.SerializeHelper.FromJson <Dictionary <string, bool> >(webRequest.downloadHandler.text); var isSuccess = ret["updated"]; if (isSuccess) { MessageBoxV2.AddMessage("更新资源成功", 4); StartCoroutine(GetArgu("Skin", config.itemId)); } } }
public void ExportRes() { Debug.Log("导出资源"); Dictionary <string, Dictionary <string, string> > TotalProperties = new Dictionary <string, Dictionary <string, string> >(); var list = GetResTransform(); foreach (var tran in list) { var BlockImageScript = tran.GetComponent <ResBlockScript>(); var properties = BlockImageScript.Properties; try { TotalProperties.Add(properties["Name"], properties); } catch (Exception ex) { Debug.Log(ex); MessageBoxV2.AddMessage("导出失败:重复的资源名称"); return; } } var dataAsJson = QF.SerializeHelper.ToJson(TotalProperties); File.WriteAllText(DirTools.GetTmpOutPutDir() + "/ResConfig.json", dataAsJson); TexturePackage(); Compress(); GenerateCode(); System.Diagnostics.Process.Start(DirTools.GetBasePathDir()); }
IEnumerator UploadConfig(AttachmentsConfig config) { var filePath = DirTools.GetOutPutDir() + "/ResConfig.zip"; if (!File.Exists(filePath)) { MessageBoxV2.AddMessage("请先导出资源!"); yield return(null); } else { FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); WWWForm form = new WWWForm(); form.AddBinaryData("file", bytes, "ResConfig.zip"); var webRequest = UnityWebRequest.Post("https://gate.mongomath.com:8443/admin-course/asset/uploadSingle", form); webRequest.SetRequestHeader("Authorization", Auth); //webRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); } else { Debug.Log(webRequest.downloadHandler.text); var dict = QF.SerializeHelper.FromJson <Dictionary <string, string> >(webRequest.downloadHandler.text); var attachment_id = dict["id"]; Debug.Log("上传成功" + attachment_id); StartCoroutine(UpdateAttachment(config, attachment_id)); } } }
IEnumerator UpdateArgu(string itemType, string itemId, string name, string content, string id) { Debug.Log("UpdateArgu"); var dict = new Dictionary <string, string>(); dict["id"] = id; dict["itemType"] = itemType; dict["itemId"] = itemId; dict["name"] = name; dict["content"] = content; var argu = QF.SerializeHelper.ToJson <Dictionary <string, string> >(dict); var webRequest = UnityWebRequest.Put("https://gate.mongomath.com:8443/admin-course/properties/" + id, argu); webRequest.SetRequestHeader("Authorization", Auth); webRequest.SetRequestHeader("Content-Type", "application/json"); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); } else { Debug.Log(webRequest.downloadHandler.text); MessageBoxV2.AddMessage("更新字段" + name); } }
private void Update() { timer -= Time.deltaTime; if (timer < 0) { MessageBoxV2.AddMessage("你好啊", 3); timer = 2; } }
void OnFilesAsync(List <string> aFiles, POINT aPos) { foreach (var path in aFiles) { MessageBoxV2.AddMessage(path); var extension = Path.GetExtension(path); var fileName = Path.GetFileName(path); var md5 = Utils.GetMD5HashFromFile(path); TypeEventSystem.Send(new FilePathInfo() { FilePath = path, Extension = extension, FileName = fileName, MD5 = md5 }); } }
public static void processCommand(string command, string argument) { using (Process process = new Process()) { process.StartInfo.FileName = command; process.StartInfo.Arguments = argument; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.Start(); StreamReader reader = process.StandardOutput; string output = reader.ReadToEnd(); UnityEngine.Debug.Log(output); MessageBoxV2.AddMessage(output, 10); process.WaitForExit(); reader.Close(); } }
IEnumerator UploadArgu(string itemType, string itemId, string name, string content) { var url = string.Format("https://gate.mongomath.com:8443/admin-course/properties"); WWWForm form = new WWWForm(); form.AddField("itemType", itemType); form.AddField("itemId", itemId); form.AddField("name", name); form.AddField("content", content); UnityWebRequest webRequest = UnityWebRequest.Post(url, form); webRequest.SetRequestHeader("Authorization", Auth); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); } else { Debug.LogWarning(webRequest.downloadHandler.text); MessageBoxV2.AddMessage("上传字段" + name); } }
IEnumerator LoginClick() { var mobile = Mobile.text; var google = Google.text; var passwd = Passwd.text; WWWForm form = new WWWForm(); form.AddField("mobile", mobile); form.AddField("nonce", google); form.AddField("password", passwd); var webRequest = UnityWebRequest.Post("https://gate.mongomath.com:8443/a/user/login", form); //webRequest.SetRequestHeader("Content-Type", "application/json"); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); } else { Debug.Log(webRequest.downloadHandler.text); var token = QF.SerializeHelper.FromJson <AccessToken>(webRequest.downloadHandler.text); if (token.access_token != null) { PlayerPrefs.SetString("access_token", "Bearer " + token.access_token); UIMgr.OpenPanel("UIActivityPanel", UILevel.Common); UIMgr.ClosePanel("UILoginPanel"); } else { MessageBoxV2.AddMessage(webRequest.downloadHandler.text); } } }
// Start is called before the first frame update void Start() { MessageBoxV2.AddMessage("aaaa"); }
protected override void OnInit(QFramework.IUIData uiData) { mData = uiData as UIResourcePanelData ?? new UIResourcePanelData(); // please add init code here var activity = mData.activityIndex; var id = mData.id; TextLabel.text = "ResArea-" + activity; var version = PlayerPrefs.GetString("Version"); gameObject.AddComponent <FileDragAndDrop>(); DirTools.ActivityIndex = activity; DirTools.Version = version; TypeEventSystem.Register <ResBlockNameChanged>(NameChanged); Export.onClick.AddListener(ExportRes); Clear.onClick.AddListener(ClearRes); God.onClick.AddListener(() => { UIMgr.OpenPanel("UIUploadPanel", UILevel.Common, new UIUploadPanelData() { ActivityIndex = activity, id = id }); }); TypeEventSystem.Register <RemoveBlock>((tmp) => { var md5 = tmp.MD5; ResMap.Remove(md5); string resDir = DirTools.GetTmpResDir(); string filepath = Path.Combine(resDir, md5 + tmp.Extension); if (File.Exists(filepath)) { File.Delete(filepath); } else { Debug.LogError("资源不存在!!!"); } }); TypeEventSystem.Register <SetBlockProperties>((tmp) => { var md5 = tmp.MD5; var properties = tmp.properties; var ResBlock = ResMap[md5]; ResBlock.GetComponent <ResBlockScript>().Properties = properties; }); TypeEventSystem.Register <ClearRescoursePanel>((tmp) => { ResMap.Clear(); var lst = new List <Transform>(); foreach (Transform child in Content) { lst.Add(child); } for (int i = 0; i < lst.Count; i++) { Destroy(lst[i].gameObject); } DirTools.DeleteFolder(DirTools.GetTmpResDir()); }); TypeEventSystem.Register <FilePathInfo>((file) => { if (ResMap.ContainsKey(file.MD5)) { return; } else if (file.Extension == ".zip") { MessageBoxV2.AddMessage("暂不支持拖入zip", 3); } else { var BlockImage = Instantiate(ResBlockPrefab, Content); BlockImage.GetComponent <ResBlockScript>().SetImage(file); DirTools.CopyDropFileToTmpResDir(file); ResMap.Add(file.MD5, BlockImage); } }); DirTools.CleanUpDir(); ResMap.Clear(); #if UNITY_EDITOR Invoke("Test", 3.0f); #endif }