完善莱医特平台对接逻辑
This commit is contained in:
parent
2ae75e1664
commit
bb0925b873
@ -25,7 +25,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
}
|
}
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
[DllImport("__Internal")]
|
[DllImport("__Internal")]
|
||||||
private static extern string GetURLParameter(string name);
|
private static extern IntPtr GetURLParameter(string name);
|
||||||
#endif
|
#endif
|
||||||
string token = string.Empty;
|
string token = string.Empty;
|
||||||
|
|
||||||
@ -42,9 +42,21 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
}
|
}
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL&&!UNITY_EDITOR
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
token = GetURLParameter("token").Replace("%2B", "+");
|
|
||||||
|
var paramPtr = GetURLParameter("token");
|
||||||
|
if (paramPtr != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
string value = Marshal.PtrToStringUTF8(paramPtr);
|
||||||
|
//token = value.Replace("%2B", "+");
|
||||||
|
token = value.Replace(" ", "+");
|
||||||
|
Marshal.FreeHGlobal(paramPtr); // 释放分配的内存
|
||||||
|
}
|
||||||
|
Debug.LogError("获取的:" + token);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RSA = Resources.Load<TextAsset>("LYTWebGL/RSA");
|
RSA = Resources.Load<TextAsset>("LYTWebGL/RSA");
|
||||||
if (string.IsNullOrEmpty(token) == false)
|
if (string.IsNullOrEmpty(token) == false)
|
||||||
{
|
{
|
||||||
@ -109,6 +121,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
step.ExpStepName = stepNames[i];
|
step.ExpStepName = stepNames[i];
|
||||||
step.maxScore = maxScore[i];
|
step.maxScore = maxScore[i];
|
||||||
step.score = score[i];
|
step.score = score[i];
|
||||||
|
list.Add(step);
|
||||||
}
|
}
|
||||||
data.ExpStepVTwoList = list.ToArray();
|
data.ExpStepVTwoList = list.ToArray();
|
||||||
|
|
||||||
@ -122,7 +135,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
Debug.LogError("ÉÏ´«½Ó¿ÚµØÖ·´íÎó:" + uploadUrl);
|
Debug.LogError("ÉÏ´«½Ó¿ÚµØÖ·´íÎó:" + uploadUrl);
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
Debug.LogError("上传的数据:" + json);
|
||||||
using (UnityWebRequest request = new UnityWebRequest(uploadUrl, "POST"))
|
using (UnityWebRequest request = new UnityWebRequest(uploadUrl, "POST"))
|
||||||
{
|
{
|
||||||
request.SetRequestHeader("Content-Type", "application/json");
|
request.SetRequestHeader("Content-Type", "application/json");
|
||||||
|
|||||||
@ -1,9 +1,17 @@
|
|||||||
// 名为 "URLParameters.jslib" 的插件文件
|
|
||||||
mergeInto(LibraryManager.library, {
|
mergeInto(LibraryManager.library, {
|
||||||
GetURLParameter: function (name) {
|
GetURLParameter: function (name) {
|
||||||
var search = window.location.search.substring(1);
|
const paramName = UTF8ToString(name);
|
||||||
var params = new URLSearchParams(search);
|
const search = window.location.search.substring(1);
|
||||||
var value = params.get(name);
|
const params = new URLSearchParams(search);
|
||||||
return value ? Pointer_stringify(value) : null;
|
const value = params.get(paramName);
|
||||||
|
console.log('GetURLParameter:', value);
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
var buffer = _malloc((value.length + 1) * 2);
|
||||||
|
stringToUTF8(value, buffer, (value.length + 1) * 2);
|
||||||
|
return buffer;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user