From c7d31c23f2e919e1bffbef6db79c7e4fef7c3145 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Wed, 9 Apr 2025 13:59:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=B9=B3=E5=8F=B0=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/UI/UIScore.cs | 14 ++- .../LYTWebGLHelper.cs} | 102 +++++++++--------- .../LYTWebGLHelper.cs.meta} | 0 Assets/WebPlatform/Scripts.meta | 8 -- 4 files changed, 65 insertions(+), 59 deletions(-) rename Assets/WebPlatform/{Scripts/WebGLHelper.cs => LaiYiTe/LYTWebGLHelper.cs} (75%) rename Assets/WebPlatform/{Scripts/WebGLHelper.cs.meta => LaiYiTe/LYTWebGLHelper.cs.meta} (100%) delete mode 100644 Assets/WebPlatform/Scripts.meta diff --git a/Assets/Scripts/UI/UIScore.cs b/Assets/Scripts/UI/UIScore.cs index bc346de6..69eb0643 100644 --- a/Assets/Scripts/UI/UIScore.cs +++ b/Assets/Scripts/UI/UIScore.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using System.Collections.Generic; using TMPro; using UnityEngine; @@ -87,7 +88,9 @@ namespace QFramework.Example onlyCur = mData.onlyCurModule; } - + List stepNames = new List(); + List maxScore = new List(); + List scores = new List(); if (onlyCur) { foreach (var item in ScoreController.Instance.GetCurScoreData()) @@ -99,6 +102,9 @@ namespace QFramework.Example obj.transform.Find("Score").GetComponent().text = item.Value.value.ToString(); sum += float.Parse(item.Value.sum); score += item.Value.value; + stepNames.Add(item.Value.step + item.Value.name); + maxScore.Add(int.Parse(item.Value.sum)); + scores.Add((int)item.Value.value); } } else @@ -114,6 +120,9 @@ namespace QFramework.Example obj.transform.Find("Score").GetComponent().text = item.Value.value.ToString(); sum += float.Parse(item.Value.sum); score += item.Value.value; + stepNames.Add(item.Value.step + item.Value.name); + maxScore.Add(int.Parse(item.Value.sum)); + scores.Add((int)item.Value.value); } } } @@ -122,6 +131,9 @@ namespace QFramework.Example this.Score.text = score.ToString(); this.Sum.text = sum.ToString(); +//#if UNITY_WEBGL +// LYTWebGLHelper.Instance.UpLoadData((int)score, stepNames, maxScore, scores); +//#endif } protected override void OnShow() diff --git a/Assets/WebPlatform/Scripts/WebGLHelper.cs b/Assets/WebPlatform/LaiYiTe/LYTWebGLHelper.cs similarity index 75% rename from Assets/WebPlatform/Scripts/WebGLHelper.cs rename to Assets/WebPlatform/LaiYiTe/LYTWebGLHelper.cs index ad0d032f..1cd7c801 100644 --- a/Assets/WebPlatform/Scripts/WebGLHelper.cs +++ b/Assets/WebPlatform/LaiYiTe/LYTWebGLHelper.cs @@ -11,9 +11,9 @@ using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; -public class WebGLHelper : Singleton +public class LYTWebGLHelper : Singleton { - private WebGLHelper() { } + private LYTWebGLHelper() { } public class LabData { public string GUID; @@ -101,10 +101,10 @@ public class WebGLHelper : Singleton } data.ExpStepVTwoList = list.ToArray(); - + SendScore(JsonConvert.SerializeObject(data)); } - IEnumerator SendScore(string json, UnityAction action) + IEnumerator SendScore(string json, UnityAction action = null) { if (string.IsNullOrEmpty(uploadUrl)) { @@ -132,58 +132,60 @@ public class WebGLHelper : Singleton Debug.Log($"Server Response: {request.downloadHandler.text}"); Response response = JsonConvert.DeserializeObject(request.downloadHandler.text); Debug.LogError(response.msg); + action?.Invoke(response.msg); } } } + + public class UploadData + { + public string GUID { get; set; } + // ʵ ID + public int ExpID { get; set; } + // ɼ + public int score { get; set; } + // ־λĬֵ true + public bool flag { get; set; } + // ʵ鲽б + public Expstepvtwolist[] ExpStepVTwoList { get; set; } + } + + public class Expstepvtwolist + { + // ʵ鲽 + public int seq { get; set; } + // ʵ鲽 + public string ExpStepName = ""; + // ʵ鲽״̬ + public string StepState = ""; + // ʵ鲽迪ʼʱ + public DateTime startTime = default; + // ʵ鲽ʱ + public DateTime endTime = default; + // ʵ鲽ʱλ + public int expectTime = 0; + // ʵ鲽֣0 ~100ٷ + public int maxScore = 100; + // ʵ鲽÷֣0 ~100ٷ + public int score = 0; + // ʵ鲽 + public int repeatCount = 1; + // ۣ200 + public string evaluation = ""; + // ģͣ200 + public string scoringModel = ""; + // ע + public string remarks { get; set; } + } + + public class Response + { + public string msg; + public bool success; + } } -public class UploadData -{ - public string GUID { get; set; } - // ʵ ID - public int ExpID { get; set; } - // ɼ - public int score { get; set; } - // ־λĬֵ true - public bool flag { get; set; } - // ʵ鲽б - public Expstepvtwolist[] ExpStepVTwoList { get; set; } -} - -public class Expstepvtwolist -{ - // ʵ鲽 - public int seq { get; set; } - // ʵ鲽 - public string ExpStepName = ""; - // ʵ鲽״̬ - public string StepState = ""; - // ʵ鲽迪ʼʱ - public DateTime startTime = default; - // ʵ鲽ʱ - public DateTime endTime = default; - // ʵ鲽ʱλ - public int expectTime = 0; - // ʵ鲽֣0 ~100ٷ - public int maxScore = 100; - // ʵ鲽÷֣0 ~100ٷ - public int score = 0; - // ʵ鲽 - public int repeatCount = 1; - // ۣ200 - public string evaluation = ""; - // ģͣ200 - public string scoringModel = ""; - // ע - public string remarks { get; set; } -} - -public class Response -{ - public string msg; - public bool success; -} \ No newline at end of file diff --git a/Assets/WebPlatform/Scripts/WebGLHelper.cs.meta b/Assets/WebPlatform/LaiYiTe/LYTWebGLHelper.cs.meta similarity index 100% rename from Assets/WebPlatform/Scripts/WebGLHelper.cs.meta rename to Assets/WebPlatform/LaiYiTe/LYTWebGLHelper.cs.meta diff --git a/Assets/WebPlatform/Scripts.meta b/Assets/WebPlatform/Scripts.meta deleted file mode 100644 index 978d3f73..00000000 --- a/Assets/WebPlatform/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b8dbba4c57255fc4495c422b41445cbe -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: