Compare commits
No commits in common. "e6ed8f3aef6f6cff6639d5620d5772df6a4adf76" and "1c472a2eac0d54c4633641bba3294838f8a691d3" have entirely different histories.
e6ed8f3aef
...
1c472a2eac
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fa05fa85bd33f6c4ca626c1e0317d53d
|
|
||||||
TextScriptImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -121,7 +121,7 @@ namespace QFramework.Example
|
|||||||
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);
|
stepNames.Add(item.Value.step + item.Value.name);
|
||||||
maxScore.Add((int)float.Parse(item.Value.sum));
|
maxScore.Add(int.Parse(item.Value.sum));
|
||||||
scores.Add((int)item.Value.value);
|
scores.Add((int)item.Value.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,22 +11,21 @@ using UnityEngine;
|
|||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
public class LYTWebGLHelper : Singleton<LYTWebGLHelper>
|
||||||
{
|
{
|
||||||
private LYTWebGLHelper() { }
|
private LYTWebGLHelper() { }
|
||||||
public class LabData
|
public class LabData
|
||||||
{
|
{
|
||||||
public string GUID;
|
public string GUID;
|
||||||
public string ExpID;
|
public string ExpID;
|
||||||
public string HOST = string.Empty;
|
public string HOST;
|
||||||
public string PARA1;
|
public string PARA1;
|
||||||
public string PARA;
|
public string PARA;
|
||||||
public string PARA2;
|
public string PARA2;
|
||||||
}
|
}
|
||||||
#if UNITY_WEBGL
|
|
||||||
[DllImport("__Internal")]
|
[DllImport("__Internal")]
|
||||||
private static extern string GetURLParameter(string name);
|
private static extern string GetURLParameter(string name);
|
||||||
#endif
|
|
||||||
string token = string.Empty;
|
string token = string.Empty;
|
||||||
|
|
||||||
LabData labData = new LabData();
|
LabData labData = new LabData();
|
||||||
@ -36,27 +35,19 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
|
|
||||||
public string uploadUrl;
|
public string uploadUrl;
|
||||||
|
|
||||||
private void Awake()
|
|
||||||
{
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL&&!UNITY_EDITOR
|
|
||||||
token = GetURLParameter("token").Replace("%2B", "+");
|
token = GetURLParameter("token").Replace("%2B", "+");
|
||||||
#endif
|
RSA = Resources.Load<TextAsset>("RSA");
|
||||||
RSA = Resources.Load<TextAsset>("LYTWebGL/RSA");
|
string urlData = Decrypt(token);
|
||||||
if (string.IsNullOrEmpty(token) == false)
|
var datas = urlData.Split("&");
|
||||||
{
|
labData.GUID = datas[0];
|
||||||
string urlData = Decrypt(token);
|
labData.ExpID = datas[1];
|
||||||
var datas = urlData.Split("&");
|
labData.HOST = datas[2];
|
||||||
labData.GUID = datas[0];
|
labData.PARA1 = datas[3];
|
||||||
labData.ExpID = datas[1];
|
labData.PARA = datas[4];
|
||||||
labData.HOST = datas[2];
|
labData.PARA2 = datas[5];
|
||||||
labData.PARA1 = datas[3];
|
|
||||||
labData.PARA = datas[4];
|
|
||||||
labData.PARA2 = datas[5];
|
|
||||||
}
|
|
||||||
uploadUrl = Path.Combine(labData.HOST, "host/public/Exp/AddScore/");
|
uploadUrl = Path.Combine(labData.HOST, "host/public/Exp/AddScore/");
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -96,9 +87,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
{
|
{
|
||||||
var data = new UploadData();
|
var data = new UploadData();
|
||||||
data.GUID = labData.GUID;
|
data.GUID = labData.GUID;
|
||||||
int expId = 0;
|
data.ExpID = int.Parse(labData.ExpID);
|
||||||
int.TryParse(labData.ExpID, out expId);
|
|
||||||
data.ExpID = expId;
|
|
||||||
data.score = totalScore;
|
data.score = totalScore;
|
||||||
data.flag = true;
|
data.flag = true;
|
||||||
|
|
||||||
@ -112,7 +101,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
}
|
}
|
||||||
data.ExpStepVTwoList = list.ToArray();
|
data.ExpStepVTwoList = list.ToArray();
|
||||||
|
|
||||||
StartCoroutine(SendScore(JsonConvert.SerializeObject(data)));
|
SendScore(JsonConvert.SerializeObject(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator SendScore(string json, UnityAction<string> action = null)
|
IEnumerator SendScore(string json, UnityAction<string> action = null)
|
||||||
@ -133,7 +122,6 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
if (request.result == UnityWebRequest.Result.ConnectionError ||
|
if (request.result == UnityWebRequest.Result.ConnectionError ||
|
||||||
request.result == UnityWebRequest.Result.ProtocolError)
|
request.result == UnityWebRequest.Result.ProtocolError)
|
||||||
{
|
{
|
||||||
Debug.LogError($"Upload failed: {request.uri}");
|
|
||||||
Debug.LogError($"Upload failed: {request.error}");
|
Debug.LogError($"Upload failed: {request.error}");
|
||||||
Debug.LogError($"Response Code: {request.responseCode}");
|
Debug.LogError($"Response Code: {request.responseCode}");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: d0622dae4bc2b2a4d937ad88a765e87a
|
guid: 72fe0ae24cde45946914fa10b54896b0
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class WebTest : MonoBehaviour
|
|
||||||
{
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
|
|
||||||
List<string> stepNames = new List<string>() { "µÚÒ»²½", "µÚ¶þ²½", "µÚÈý²½" };
|
|
||||||
List<int> maxScore = new List<int>() { 10, 20, 30 };
|
|
||||||
List<int> score = new List<int>() { 5, 10, 15 };
|
|
||||||
LYTWebGLHelper.Instance.UpLoadData(60, stepNames, maxScore, score);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 08f51ad357b70604492d4c3e95ce1e27
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Loading…
x
Reference in New Issue
Block a user