完善平台对接代码
This commit is contained in:
parent
b8abfa3c44
commit
c7d31c23f2
@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -87,7 +88,9 @@ namespace QFramework.Example
|
|||||||
onlyCur = mData.onlyCurModule;
|
onlyCur = mData.onlyCurModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<string> stepNames = new List<string>();
|
||||||
|
List<int> maxScore = new List<int>();
|
||||||
|
List<int> scores = new List<int>();
|
||||||
if (onlyCur)
|
if (onlyCur)
|
||||||
{
|
{
|
||||||
foreach (var item in ScoreController.Instance.GetCurScoreData())
|
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();
|
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
||||||
sum += float.Parse(item.Value.sum);
|
sum += float.Parse(item.Value.sum);
|
||||||
score += item.Value.value;
|
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
|
else
|
||||||
@ -114,6 +120,9 @@ namespace QFramework.Example
|
|||||||
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
||||||
sum += float.Parse(item.Value.sum);
|
sum += float.Parse(item.Value.sum);
|
||||||
score += item.Value.value;
|
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.Score.text = score.ToString();
|
||||||
this.Sum.text = sum.ToString();
|
this.Sum.text = sum.ToString();
|
||||||
|
|
||||||
|
//#if UNITY_WEBGL
|
||||||
|
// LYTWebGLHelper.Instance.UpLoadData((int)score, stepNames, maxScore, scores);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnShow()
|
protected override void OnShow()
|
||||||
|
|||||||
@ -11,9 +11,9 @@ using UnityEngine;
|
|||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
public class WebGLHelper : Singleton<WebGLHelper>
|
public class LYTWebGLHelper : Singleton<LYTWebGLHelper>
|
||||||
{
|
{
|
||||||
private WebGLHelper() { }
|
private LYTWebGLHelper() { }
|
||||||
public class LabData
|
public class LabData
|
||||||
{
|
{
|
||||||
public string GUID;
|
public string GUID;
|
||||||
@ -101,10 +101,10 @@ public class WebGLHelper : Singleton<WebGLHelper>
|
|||||||
}
|
}
|
||||||
data.ExpStepVTwoList = list.ToArray();
|
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))
|
if (string.IsNullOrEmpty(uploadUrl))
|
||||||
{
|
{
|
||||||
@ -132,14 +132,11 @@ public class WebGLHelper : Singleton<WebGLHelper>
|
|||||||
Debug.Log($"Server Response: {request.downloadHandler.text}");
|
Debug.Log($"Server Response: {request.downloadHandler.text}");
|
||||||
Response response = JsonConvert.DeserializeObject<Response>(request.downloadHandler.text);
|
Response response = JsonConvert.DeserializeObject<Response>(request.downloadHandler.text);
|
||||||
Debug.LogError(response.msg);
|
Debug.LogError(response.msg);
|
||||||
|
action?.Invoke(response.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class UploadData
|
public class UploadData
|
||||||
{
|
{
|
||||||
@ -187,3 +184,8 @@ public class Response
|
|||||||
public string msg;
|
public string msg;
|
||||||
public bool success;
|
public bool success;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b8dbba4c57255fc4495c422b41445cbe
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Loading…
x
Reference in New Issue
Block a user