|
@@ -1,12 +1,7 @@
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
-using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
-using System.Text;
|
|
|
using Blue;
|
|
|
-using LitJson;
|
|
|
-using Newtonsoft.Json;
|
|
|
-using Newtonsoft.Json.Linq;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
@@ -32,20 +27,15 @@ public interface IPointService:IService
|
|
|
|
|
|
|
|
|
void DownloadPointFile(string downloadingUrl, PointFileType fileType);
|
|
|
-
|
|
|
- void GetRefrencePos(int sceneID);
|
|
|
}
|
|
|
|
|
|
public class PointService : IPointService
|
|
|
{
|
|
|
- public ScenePosRotInfo PosRot { get; private set; }
|
|
|
private string UrlPointCloud;
|
|
|
- private string UrlObjOfReference;
|
|
|
public void OnInit()
|
|
|
{
|
|
|
-
|
|
|
- UrlPointCloud = "https://api-cs.ghz-tech.com/mr-navigator/v1";
|
|
|
- UrlObjOfReference = "https://api-fat3.ghz-tech.com/mr-navigator/v1/project/unityReference";
|
|
|
+
|
|
|
+ UrlPointCloud = "https://api-fat2.ghz-tech.com/mr-navigator/v1";
|
|
|
}
|
|
|
|
|
|
public void GetPoint(string methodName, Action<string> callback)
|
|
@@ -59,6 +49,7 @@ public class PointService : IPointService
|
|
|
UriBuilder uriBuilder = new UriBuilder(url);
|
|
|
|
|
|
uriBuilder.Query = "projectId=" + projectId + "&fileType=" + fileType.ToString();
|
|
|
+ Debug.Log(uriBuilder.Uri);
|
|
|
|
|
|
UnityWebRequest webRequest = UnityWebRequest.Get(uriBuilder.Uri);
|
|
|
webRequest.SetRequestHeader("Authorization", UserInfo.Instance.Token);
|
|
@@ -70,11 +61,6 @@ public class PointService : IPointService
|
|
|
CoroutineSystem.Instance.Start_Coroutine(DownloadPointFileRequest(downloadingUrl,fileType));
|
|
|
}
|
|
|
|
|
|
- public void GetRefrencePos(int sceneID)
|
|
|
- {
|
|
|
- CoroutineSystem.Instance.Start_Coroutine(GetObjectOfRefrence(UrlObjOfReference,sceneID));
|
|
|
- }
|
|
|
-
|
|
|
#region 协程
|
|
|
|
|
|
private IEnumerator GetPointRequest(string methodName, Action<string> callback)
|
|
@@ -139,7 +125,7 @@ public class PointService : IPointService
|
|
|
nFile.Write(File, 0, File.Length);
|
|
|
nFile.Close(); nFile.Dispose(); nFile = null;
|
|
|
if (fileType == PointFileType.bytes)
|
|
|
- this.SendEvent(new LoadMapFileEvent() { fileName = fileName });
|
|
|
+ this.TriggerEvent(new LoadMapFileEvent() { fileName = fileName });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -148,48 +134,9 @@ public class PointService : IPointService
|
|
|
{
|
|
|
Debug.LogWarning("文件已存在");
|
|
|
if (fileType == PointFileType.bytes)
|
|
|
- this.SendEvent(new LoadMapFileEvent() { fileName = fileName });
|
|
|
+ this.TriggerEvent(new LoadMapFileEvent() { fileName = fileName });
|
|
|
}
|
|
|
}
|
|
|
- private IEnumerator GetObjectOfRefrence(string url,int sceneID)
|
|
|
- {
|
|
|
- using (UnityWebRequest webRequest = new UnityWebRequest(url, "POST"))
|
|
|
- {
|
|
|
- ObjofRefrendenceInfo TestGet = new ObjofRefrendenceInfo();
|
|
|
- TestGet.id = sceneID;
|
|
|
- string jsonData = JsonConvert.SerializeObject(TestGet);
|
|
|
- byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonData);
|
|
|
-
|
|
|
- webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
|
|
|
- webRequest.downloadHandler = new DownloadHandlerBuffer();
|
|
|
-
|
|
|
- webRequest.SetRequestHeader("Content-Type", "application/json;charset=utf-8");
|
|
|
- webRequest.SetRequestHeader("authorization", UserInfo.Instance.Token);
|
|
|
|
|
|
- yield return webRequest.SendWebRequest();
|
|
|
-
|
|
|
- if (webRequest.result== UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
|
|
|
- Debug.LogError("UnityWebRequest Error:"+webRequest.downloadHandler.text);
|
|
|
- else
|
|
|
- {
|
|
|
- if (!string.IsNullOrWhiteSpace(webRequest.downloadHandler.text))
|
|
|
- {
|
|
|
- string message = webRequest.downloadHandler.text;
|
|
|
- JObject jobject = JObject.Parse(message);
|
|
|
- if (jobject["code"].ToString() == "200")
|
|
|
- {
|
|
|
- message = jobject["data"].ToString();
|
|
|
- if (!string.IsNullOrWhiteSpace(message))
|
|
|
- {
|
|
|
-
|
|
|
- ScenePosRotInfo ScenePosRotInfoList = JsonConvert.DeserializeObject<ScenePosRotInfo>(message);
|
|
|
- PosRot = ScenePosRotInfoList;
|
|
|
- this.SendEvent(new GetReferencePosEvent() { PosRot = PosRot });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
#endregion
|
|
|
}
|