Compare commits
2 Commits
e5324ab48f
...
0a80f3778b
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a80f3778b | |||
| c1de962908 |
@@ -1,6 +1,5 @@
|
|||||||
using RTG;
|
using RTG;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class RTGController : UnitySingleton<RTGController>
|
public class RTGController : UnitySingleton<RTGController>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace Octopus.Simulator
|
|||||||
|
|
||||||
public event Action<LogicData> onLogicUpdated;
|
public event Action<LogicData> onLogicUpdated;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -34,6 +36,8 @@ namespace Octopus.Simulator
|
|||||||
GetDataFromInfo(info.data);
|
GetDataFromInfo(info.data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WebManager.Instance.Reqeust_Get<LogicInfo>($"{WebManager.Instance.apiConfig.logic}/{WebParameters.config.logicId}",GetDataFromResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetDataFromInfo(LogicData Data)
|
void GetDataFromInfo(LogicData Data)
|
||||||
@@ -51,5 +55,10 @@ namespace Octopus.Simulator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetDataFromResponse(LogicInfo response)
|
||||||
|
{
|
||||||
|
Debug.Log(response.data.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace UVC.Networks
|
namespace UVC.Networks
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,8 @@ namespace UVC.Networks
|
|||||||
//Post, Get. Put을 사용하며, Post의 경우엔 Class를 입력으로 받아 Json형식으로 변환하여 업로드합니다.
|
//Post, Get. Put을 사용하며, Post의 경우엔 Class를 입력으로 받아 Json형식으로 변환하여 업로드합니다.
|
||||||
//비동기로 실행하기 위해 Coroutine으로 제작되었으며, callback의 bool값을 통해 서버로부터
|
//비동기로 실행하기 위해 Coroutine으로 제작되었으며, callback의 bool값을 통해 서버로부터
|
||||||
//정상적으로 API가 입력, 결과가 출력되었는지를 확인할 수 있습니다.
|
//정상적으로 API가 입력, 결과가 출력되었는지를 확인할 수 있습니다.
|
||||||
|
|
||||||
|
|
||||||
public class WebManager : MonoBehaviour
|
public class WebManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
static WebManager webManager;
|
static WebManager webManager;
|
||||||
@@ -210,5 +213,94 @@ namespace UVC.Networks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//별도의 Data Content 가 없을 경우 reqeustURL 과 callback 등 만을 parameter로 넘기면 됨
|
||||||
|
public void Reqeust_Get<T>(string requestURL, Action<T> callback, string json = "")
|
||||||
|
{
|
||||||
|
StartCoroutine(Reqeuest(_webConfigLoader.BaseUrl + requestURL, RequestType.GET, callback, json));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reqeust_Post<T>(string requestURL, Action<T> callback, string json = "")
|
||||||
|
{
|
||||||
|
StartCoroutine(Reqeuest(_webConfigLoader.BaseUrl + requestURL, RequestType.POST, callback, json));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Reqeust_Put<T>(string requestURL, Action<T> callback, string json = "")
|
||||||
|
{
|
||||||
|
StartCoroutine(Reqeuest(_webConfigLoader.BaseUrl + requestURL, RequestType.PUT, callback, json));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Reqeust_Patch<T>(string requestURL, Action<T> callback, string json = "")
|
||||||
|
{
|
||||||
|
StartCoroutine(Reqeuest(_webConfigLoader.BaseUrl + requestURL, RequestType.PATCH, callback, json));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Reqeust_Delete<T>(string requestURL, Action<T> callback, string json = "")
|
||||||
|
{
|
||||||
|
StartCoroutine(Reqeuest(_webConfigLoader.BaseUrl + requestURL, RequestType.DELETE, callback, json));
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RequestType
|
||||||
|
{
|
||||||
|
//"GET", "POST", "PUT", "PATCH", "DELETE"
|
||||||
|
GET,
|
||||||
|
POST,
|
||||||
|
PUT,
|
||||||
|
PATCH,
|
||||||
|
DELETE,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator Reqeuest<T>(string URL,RequestType type, System.Action<T> callback, string json)
|
||||||
|
{
|
||||||
|
using (UnityWebRequest request = new UnityWebRequest(URL, type.ToString()))
|
||||||
|
{
|
||||||
|
byte[] body = System.Text.Encoding.UTF8.GetBytes(json);
|
||||||
|
request.uploadHandler = new UploadHandlerRaw(body);
|
||||||
|
|
||||||
|
request.downloadHandler = new DownloadHandlerBuffer();
|
||||||
|
|
||||||
|
request.SetRequestHeader("Content-Type", "application/json");
|
||||||
|
request.SetRequestHeader("Authorization", "Bearer " + _webConfigLoader.Token);
|
||||||
|
|
||||||
|
yield return request.SendWebRequest();
|
||||||
|
|
||||||
|
if (IsSuccess(request.result))
|
||||||
|
{
|
||||||
|
string responseJson = request.downloadHandler.text;
|
||||||
|
T result = JsonConvert.DeserializeObject<T>(responseJson);
|
||||||
|
callback?.Invoke(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//통신 실패 시 에러 팝업 추후 추가
|
||||||
|
Debug.Log($"Request failed, API Name {URL}, Result :{request.error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool IsSuccess(UnityWebRequest.Result result)
|
||||||
|
{
|
||||||
|
switch(result)
|
||||||
|
{
|
||||||
|
case UnityWebRequest.Result.Success:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case UnityWebRequest.Result.ConnectionError:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case UnityWebRequest.Result.ProtocolError:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,11 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.ai.navigation": "2.0.5",
|
|
||||||
"com.unity.collab-proxy": "2.7.1",
|
|
||||||
"com.unity.ide.rider": "3.0.31",
|
|
||||||
"com.unity.ide.visualstudio": "2.0.22",
|
"com.unity.ide.visualstudio": "2.0.22",
|
||||||
"com.unity.inputsystem": "1.11.2",
|
"com.unity.inputsystem": "1.11.2",
|
||||||
"com.unity.multiplayer.center": "1.0.0",
|
|
||||||
"com.unity.nuget.newtonsoft-json": "3.2.1",
|
"com.unity.nuget.newtonsoft-json": "3.2.1",
|
||||||
"com.unity.render-pipelines.universal": "17.0.3",
|
"com.unity.render-pipelines.universal": "17.0.3",
|
||||||
"com.unity.test-framework": "1.4.5",
|
|
||||||
"com.unity.timeline": "1.8.7",
|
"com.unity.timeline": "1.8.7",
|
||||||
"com.unity.ugui": "2.0.0",
|
"com.unity.ugui": "2.0.0",
|
||||||
"com.unity.visualscripting": "1.9.5",
|
|
||||||
"com.unity.modules.accessibility": "1.0.0",
|
"com.unity.modules.accessibility": "1.0.0",
|
||||||
"com.unity.modules.ai": "1.0.0",
|
"com.unity.modules.ai": "1.0.0",
|
||||||
"com.unity.modules.androidjni": "1.0.0",
|
"com.unity.modules.androidjni": "1.0.0",
|
||||||
|
|||||||
@@ -36,15 +36,6 @@
|
|||||||
"com.tivadar.best.http": "3.0.10"
|
"com.tivadar.best.http": "3.0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.unity.ai.navigation": {
|
|
||||||
"version": "2.0.5",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "registry",
|
|
||||||
"dependencies": {
|
|
||||||
"com.unity.modules.ai": "1.0.0"
|
|
||||||
},
|
|
||||||
"url": "https://packages.unity.com"
|
|
||||||
},
|
|
||||||
"com.unity.burst": {
|
"com.unity.burst": {
|
||||||
"version": "1.8.19",
|
"version": "1.8.19",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
@@ -55,13 +46,6 @@
|
|||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.collab-proxy": {
|
|
||||||
"version": "2.7.1",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "registry",
|
|
||||||
"dependencies": {},
|
|
||||||
"url": "https://packages.unity.com"
|
|
||||||
},
|
|
||||||
"com.unity.collections": {
|
"com.unity.collections": {
|
||||||
"version": "2.5.1",
|
"version": "2.5.1",
|
||||||
"depth": 2,
|
"depth": 2,
|
||||||
@@ -76,20 +60,11 @@
|
|||||||
},
|
},
|
||||||
"com.unity.ext.nunit": {
|
"com.unity.ext.nunit": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
"depth": 1,
|
"depth": 2,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.ide.rider": {
|
|
||||||
"version": "3.0.31",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "registry",
|
|
||||||
"dependencies": {
|
|
||||||
"com.unity.ext.nunit": "1.0.6"
|
|
||||||
},
|
|
||||||
"url": "https://packages.unity.com"
|
|
||||||
},
|
|
||||||
"com.unity.ide.visualstudio": {
|
"com.unity.ide.visualstudio": {
|
||||||
"version": "2.0.22",
|
"version": "2.0.22",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
@@ -115,14 +90,6 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.multiplayer.center": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "builtin",
|
|
||||||
"dependencies": {
|
|
||||||
"com.unity.modules.uielements": "1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"com.unity.nuget.mono-cecil": {
|
"com.unity.nuget.mono-cecil": {
|
||||||
"version": "1.11.4",
|
"version": "1.11.4",
|
||||||
"depth": 3,
|
"depth": 3,
|
||||||
@@ -205,7 +172,7 @@
|
|||||||
},
|
},
|
||||||
"com.unity.test-framework": {
|
"com.unity.test-framework": {
|
||||||
"version": "1.4.5",
|
"version": "1.4.5",
|
||||||
"depth": 0,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.ext.nunit": "2.0.3",
|
"com.unity.ext.nunit": "2.0.3",
|
||||||
@@ -245,16 +212,6 @@
|
|||||||
"com.unity.modules.imgui": "1.0.0"
|
"com.unity.modules.imgui": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.unity.visualscripting": {
|
|
||||||
"version": "1.9.5",
|
|
||||||
"depth": 0,
|
|
||||||
"source": "registry",
|
|
||||||
"dependencies": {
|
|
||||||
"com.unity.ugui": "1.0.0",
|
|
||||||
"com.unity.modules.jsonserialize": "1.0.0"
|
|
||||||
},
|
|
||||||
"url": "https://packages.unity.com"
|
|
||||||
},
|
|
||||||
"com.unity.modules.accessibility": {
|
"com.unity.modules.accessibility": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user