/// <summary> /// 调用接口 /// </summary> /// <param name="labInterType"></param> /// <param name="requsetData"></param> /// <returns></returns> public void LabRequest(LabInterType labInterType, string requsetData = "") { //显示遮罩 ScreenMask.ShowMask(new Color(1, 1, 1, 0.7f), MaskType.BigSpinner); requestInterType = labInterType; //设置请求json格式 byte[] postBtye = System.Text.Encoding.UTF8.GetBytes(requsetData); string postData = System.Convert.ToBase64String(postBtye); StartCoroutine(ExcuteRequest(_labInterUrl[labInterType], postData)); }
/// <summary> /// 请求回调,包含状态码和返回数据 /// </summary> /// <param name="responseCode"></param> /// <param name="data"></param> protected void WebRequestCallBack(long responseCode, string data) { byte[] data64 = System.Convert.FromBase64String(data); string result = System.Text.Encoding.UTF8.GetString(data64); JObject jObject = _serviceSerializer.DeSerializerObject <JObject>(result); if (jObject["status"].ToString().Equals("101")) { Debug.Log(requestInterType + "服务器返回异常" + result); return; } switch (requestInterType) { case LabInterType.login: SetLabInfoParams(result); if (RequestCallBack != null) { RequestCallBack(result); } break; case LabInterType.uploadIgcs: Debug.Log("上传智能批改数据请求返回信息:[" + result + "]"); break; case LabInterType.uploadRepay: Debug.Log("上传实验数据请求返回信息:[" + result + "]"); break; case LabInterType.downloadReplay: Debug.Log("下载实验数据请求返回信息:[" + result + "]"); RequestCallBack(jObject["initScript"].ToString()); break; default: break; } //关闭遮罩 ScreenMask.HideMask(); }
private void OnGUI() { if (menuState == 1 && GUILayout.Button("StorageToSave")) { _storageSystem.SaveStorageData(); } if (menuState == 1 && GUILayout.Button("IgcsXmlToSave")) { _storageSystem.SaveIgcsData(); } if (menuState == 1 && GUILayout.Button("StorageToLoad")) { _storageSystem.LoadStorageData(); menuState = 2; } if (menuState == 2) { if (GUILayout.Button("ReplayScene")) { menuState = 3; } if (GUILayout.Button("ReBackScene")) { _storageSystem.RestoreScene(); ScreenMask.ShowMask(Color.black, 3, MaskType.BigBar); } if (GUILayout.Button("Back")) { menuState = 1; } } if (menuState == 3) { GUILayout.BeginHorizontal(); #if UNITY_EDITOR if (GUILayout.Button(EditorGUIUtility.FindTexture(playButton))) { if (!IsPlaying) { IsPlaying = true; _storageSystem.BeginReplay(() => { IsPlaying = false; Time.timeScale = 1; }); } else { IsPause = !IsPause; } } #else if (GUILayout.Button(buttonState)) { if (!IsPlaying) { IsPlaying = true; _storageSystem.BeginReplay(() => IsPlaying = false); } else { IsPause = !IsPause; } } #endif SelectSpeed = GUILayout.Toolbar(SelectSpeed, new string[] { "1.0", "2.0", "3.0" }); GUILayout.EndHorizontal(); GUILayout.HorizontalSlider(MemoryPlayer.Percent, 0f, 1.00f); if (GUILayout.Button("Back")) { menuState = 2; } } }
/// <summary> /// 场景还原 /// </summary> public void RestoreScene() { _storageSystem.RestoreScene(); ScreenMask.ShowMask(Color.black, 3, MaskType.BigBar); }