Commit 871fad6b authored by 潘梓豪's avatar 潘梓豪

更新

parent 449ed984
......@@ -2,7 +2,6 @@ using System.Collections;
using UnityEngine.Networking;
using UnityEngine;
using TMPro;
using System.IO;
using LitJson;
using System;
......@@ -87,9 +86,11 @@ public class LoginManager : MonoBehaviour
{
while (true)
{
if (!String.IsNullOrEmpty(productionlineID.text))
{
using (UnityWebRequest request = UnityWebRequest.Get(productionlineID.text))
{
Debug.Log(productionlineID.text);
// 设置请求头
request.SetRequestHeader("Content-Type", "application/json");
......@@ -107,12 +108,12 @@ public class LoginManager : MonoBehaviour
Debug.Log("Response: " + responseJson);
// 使用 JsonUtility 解析 JSON 数据
positionData = JsonUtility.FromJson<RobotPositionData>(responseJson);
positionData = JsonMapper.ToObject<RobotPositionData>(responseJson);
OnReceiveMsg.Invoke(positionData, "RobotPositionData");
IsDataLoaded = true;
}
}
}
yield return new WaitForSeconds(1);
}
}
......@@ -122,6 +123,8 @@ public class LoginManager : MonoBehaviour
string jsonData = "{\"lineId\":\"" + lineID.text + "\"}";
while (true)
{
if (!String.IsNullOrEmpty(faultInterface.text))
{
using (UnityWebRequest request = UnityWebRequest.PostWwwForm(faultInterface.text, jsonData))
{
......@@ -145,7 +148,7 @@ public class LoginManager : MonoBehaviour
string responseJson = request.downloadHandler.text;
// 使用 JsonUtility 解析 JSON 数据
faultData = JsonUtility.FromJson<FaultEventData>(responseJson);
faultData = JsonMapper.ToObject<FaultEventData>(responseJson);
// 检查是否成功拿到数据
......@@ -160,6 +163,7 @@ public class LoginManager : MonoBehaviour
}
}
}
}
yield return new WaitForSeconds(5f);
}
}
......@@ -167,6 +171,8 @@ public class LoginManager : MonoBehaviour
private IEnumerator GetThreeModelSensorData()
{
while (true)
{
if (!String.IsNullOrEmpty(post_url.text))
{
using (UnityWebRequest request = UnityWebRequest.Get(post_url.text + "?lineId=" + lineID.text))
{
......@@ -191,6 +197,7 @@ public class LoginManager : MonoBehaviour
}
}
}
}
yield return new WaitForSeconds(1f);
}
}
......@@ -268,11 +275,13 @@ public class LoginManager : MonoBehaviour
rq.SetRequestHeader("Access-Control-Allow-Origin", "*");
rq.SetRequestHeader("Accept", "*");
yield return rq.SendWebRequest();
if (string.IsNullOrEmpty(rq.error))
{
try
{
inputFieldData = JsonUtility.FromJson<InputFieldData>(rq.downloadHandler.text);
inputFieldData = JsonMapper.ToObject<InputFieldData>(rq.downloadHandler.text);
Debug.Log(rq.downloadHandler.text);
if (IsLine1)
{
productionlineID.text = inputFieldData.productionlineID1;
......
......@@ -5,7 +5,7 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
- enabled: 0
path: Assets/_Scenes/1_Main.unity
guid: a1193329f89803b4f8a14f6c0b15d2c1
- enabled: 0
......@@ -14,7 +14,7 @@ EditorBuildSettings:
- enabled: 0
path: Assets/_Scenes/3_Main.unity
guid: 20c0c67e1155d7340be70873c2eb30f1
- enabled: 0
- enabled: 1
path: Assets/_Scenes/4_Main.unity
guid: da74b35adf3770040b51552fc0cb9a98
- enabled: 0
......
......@@ -653,7 +653,7 @@ PlayerSettings:
webGLDebugSymbols: 0
webGLEmscriptenArgs:
webGLModulesDirectory:
webGLTemplate: APPLICATION:Default
webGLTemplate: PROJECT:ZeusWebGL
webGLAnalyzeBuildSize: 0
webGLUseEmbeddedResources: 0
webGLCompressionFormat: 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment