完善平台对接代码

This commit is contained in:
shenjianxing 2025-04-09 13:59:32 +08:00
parent b8abfa3c44
commit c7d31c23f2
4 changed files with 65 additions and 59 deletions

View File

@ -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<string> stepNames = new List<string>();
List<int> maxScore = new List<int>();
List<int> scores = new List<int>();
if (onlyCur)
{
foreach (var item in ScoreController.Instance.GetCurScoreData())
@ -99,6 +102,9 @@ namespace QFramework.Example
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().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<TextMeshProUGUI>().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()

View File

@ -11,9 +11,9 @@ using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
public class WebGLHelper : Singleton<WebGLHelper>
public class LYTWebGLHelper : Singleton<LYTWebGLHelper>
{
private WebGLHelper() { }
private LYTWebGLHelper() { }
public class LabData
{
public string GUID;
@ -101,10 +101,10 @@ public class WebGLHelper : Singleton<WebGLHelper>
}
data.ExpStepVTwoList = list.ToArray();
SendScore(JsonConvert.SerializeObject(data));
}
IEnumerator SendScore(string json, UnityAction<string> action)
IEnumerator SendScore(string json, UnityAction<string> action = null)
{
if (string.IsNullOrEmpty(uploadUrl))
{
@ -132,17 +132,14 @@ public class WebGLHelper : Singleton<WebGLHelper>
Debug.Log($"Server Response: {request.downloadHandler.text}");
Response response = JsonConvert.DeserializeObject<Response>(request.downloadHandler.text);
Debug.LogError(response.msg);
action?.Invoke(response.msg);
}
}
}
}
public class UploadData
{
public class UploadData
{
public string GUID { get; set; }
// 实验 ID
public int ExpID { get; set; }
@ -152,10 +149,10 @@ public class UploadData
public bool flag { get; set; }
// 实验步骤列表
public Expstepvtwolist[] ExpStepVTwoList { get; set; }
}
}
public class Expstepvtwolist
{
public class Expstepvtwolist
{
// 实验步骤序号
public int seq { get; set; }
// 实验步骤名称
@ -180,10 +177,15 @@ public class Expstepvtwolist
public string scoringModel = "";
// 备注
public string remarks { get; set; }
}
}
public class Response
{
public class Response
{
public string msg;
public bool success;
}
}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b8dbba4c57255fc4495c422b41445cbe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: