完善莱医特平台对接逻辑
This commit is contained in:
parent
2ae75e1664
commit
bb0925b873
@ -25,7 +25,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
||||
}
|
||||
#if UNITY_WEBGL
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetURLParameter(string name);
|
||||
private static extern IntPtr GetURLParameter(string name);
|
||||
#endif
|
||||
string token = string.Empty;
|
||||
|
||||
@ -43,8 +43,20 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
||||
public void Init()
|
||||
{
|
||||
#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
|
||||
|
||||
|
||||
|
||||
RSA = Resources.Load<TextAsset>("LYTWebGL/RSA");
|
||||
if (string.IsNullOrEmpty(token) == false)
|
||||
{
|
||||
@ -109,6 +121,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
||||
step.ExpStepName = stepNames[i];
|
||||
step.maxScore = maxScore[i];
|
||||
step.score = score[i];
|
||||
list.Add(step);
|
||||
}
|
||||
data.ExpStepVTwoList = list.ToArray();
|
||||
|
||||
@ -122,7 +135,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
||||
Debug.LogError("ÉÏ´«½Ó¿ÚµØÖ·´íÎó:" + uploadUrl);
|
||||
yield break;
|
||||
}
|
||||
|
||||
Debug.LogError("上传的数据:" + json);
|
||||
using (UnityWebRequest request = new UnityWebRequest(uploadUrl, "POST"))
|
||||
{
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
|
||||
@ -1,9 +1,17 @@
|
||||
// 名为 "URLParameters.jslib" 的插件文件
|
||||
mergeInto(LibraryManager.library, {
|
||||
GetURLParameter: function (name) {
|
||||
var search = window.location.search.substring(1);
|
||||
var params = new URLSearchParams(search);
|
||||
var value = params.get(name);
|
||||
return value ? Pointer_stringify(value) : null;
|
||||
const paramName = UTF8ToString(name);
|
||||
const search = window.location.search.substring(1);
|
||||
const params = new URLSearchParams(search);
|
||||
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