This commit is contained in:
2025-07-15 18:07:24 +09:00
parent 83db394a70
commit 64c94474d2
26 changed files with 258 additions and 109 deletions

View File

@@ -1,16 +1,6 @@
using UnityEngine;
using UnityEngine;
public class Canvas_Bottom : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

5
Assets/Canvas_Main.cs Normal file
View File

@@ -0,0 +1,5 @@
using UnityEngine;
public class Canvas_Main : MonoBehaviour
{
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ad17c40cd0dc74549b72315f71c1d058

View File

@@ -243,7 +243,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &8129750435633852209
RectTransform:
m_ObjectHideFlags: 0
@@ -261,7 +261,7 @@ RectTransform:
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -15, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_SizeDelta: {x: 10, y: 1}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &36653752599771273
CanvasRenderer:
@@ -1068,13 +1068,15 @@ GameObject:
- component: {fileID: 7017054633992713509}
- component: {fileID: 5043269982290365068}
- component: {fileID: 8463000448564215879}
- component: {fileID: -8858190357896567494}
- component: {fileID: -1127188932545254283}
m_Layer: 5
m_Name: UIAlert
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &7017054633992713509
RectTransform:
m_ObjectHideFlags: 0
@@ -1136,3 +1138,33 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!225 &-8858190357896567494
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8532598515549271824}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!114 &-1127188932545254283
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8532598515549271824}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: df24e34663a0c284fab8f402000f0bcd, type: 3}
m_Name:
m_EditorClassIdentifier:
OnOk:
m_PersistentCalls:
m_Calls: []
OnCancel:
m_PersistentCalls:
m_Calls: []

View File

@@ -333,7 +333,7 @@ RectTransform:
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -15, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_SizeDelta: {x: 10, y: 10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &67351207
MonoBehaviour:
@@ -6170,6 +6170,7 @@ GameObject:
- component: {fileID: 1916153469}
- component: {fileID: 1916153468}
- component: {fileID: 1916153467}
- component: {fileID: 1916153471}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
@@ -6259,7 +6260,6 @@ RectTransform:
- {fileID: 2078174713}
- {fileID: 1337840807}
- {fileID: 1350516101}
- {fileID: 7027186561456478243}
- {fileID: 696682472}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -6268,6 +6268,18 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1916153471
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916153466}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ad17c40cd0dc74549b72315f71c1d058, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1925377959
GameObject:
m_ObjectHideFlags: 0
@@ -7189,10 +7201,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ReferenceResolution: {x: 1920, y: 1080}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
@@ -7695,10 +7707,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ReferenceResolution: {x: 1920, y: 1080}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
@@ -9011,7 +9023,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2430122421531363926}
m_HandleRect: {fileID: 1792930014543576916}
m_Direction: 2
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
@@ -9088,11 +9100,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 588411198089990919, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
propertyPath: m_Size
value: 0.79725
value: 0.9149859
objectReference: {fileID: 0}
- target: {fileID: 588411198089990919, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
propertyPath: m_Value
value: 0.6999999
value: 0.69999987
objectReference: {fileID: 0}
- target: {fileID: 1073750513953127727, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
propertyPath: m_Type
@@ -9296,7 +9308,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 6940169657633229565, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
propertyPath: m_Value
value: 0.65
value: 0.65000004
objectReference: {fileID: 0}
- target: {fileID: 7672464725508683099, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
propertyPath: m_Colors.m_SelectedColor.b
@@ -9685,20 +9697,20 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1204438133335786704}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5239015192560940965}
- {fileID: 6023202728124299781}
m_Father: {fileID: 1916153470}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
m_Pivot: {x: 0, y: 0}
--- !u!114 &7062256588867111173
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -10339,6 +10351,7 @@ SceneRoots:
m_Roots:
- {fileID: 1872009199}
- {fileID: 1661135200126774734}
- {fileID: 7027186561456478243}
- {fileID: 1916153470}
- {fileID: 1899099861}
- {fileID: 602269599}

View File

@@ -1,69 +0,0 @@
using Cysharp.Threading.Tasks;
using UnityEngine;
public class AlertManager : UnitySingleton<AlertManager>
{
private GameObject prefab;
private UIAlert alert;
private void Create()
{
if (alert == null)
{
if (prefab == null)
{
prefab = Resources.Load("Prefabs/Popup/UIAlert", typeof(GameObject)) as GameObject;
}
GameObject go = UnityEngine.Object.Instantiate(prefab);
alert = go.GetComponent<UIAlert>();
}
//var canvas = FindAnyObjectByType<Canvas_Label>();
//alert.transform.SetParent(canvas.Canvas.rootCanvas.transform, false);
}
//public async UniTask ShowAlert(string title, string message, string okButtonTitle = "OK")
//{
// Create();
// bool isClosed = false;
// alert.Init(title: title, message: message, okButtonText: okButtonTitle, showCancelButton: false);
// alert.OnOk.AddListener(() =>
// {
// isClosed = true;
// });
// alert.Open();
// await UniTask.WaitUntil(() => isClosed == true);
//}
//public async UniTask<bool> ShowConfirm(string title, string message, string okButtonTitle = "OK", string cancelButtonTitle = "CANCEL")
//{
// Create();
// bool isClosed = false;
// bool result = false;
// alert.Init(title, message, okButtonTitle, cancelButtonTitle, true);
// alert.OnOk.AddListener(() =>
// {
// result = true;
// isClosed = true;
// });
// alert.OnCancel.AddListener(() =>
// {
// result = false;
// isClosed = true;
// });
// alert.Open();
// await UniTask.WaitUntil(() => isClosed == true);
// return result;
//}
}

View File

@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
using System;
using UnityEngine.SceneManagement;
@@ -31,7 +31,10 @@ public class Popup_Reset : MonoBehaviour
void Confirm()
{
loadingSpinner.gameObject.SetActive(true);
//여기에 카메라 저장
string requestURL = $"{WebManager.Instance.apiConfig.history}/{WebParameters.id}/pause";
MQTTManager.mqttManager.isSceneReroad = true;
WebManager.Instance.Reqeust<emptyClass>(requestURL, RequestType.POST, (value)=>SceneManager.LoadScene(0));
Confirm_Button.interactable = false;
Cancel_Button.interactable = false;

View File

@@ -6,6 +6,7 @@ using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.SceneManagement;
namespace Octopus.Simulator.Networks
{
@@ -21,7 +22,7 @@ namespace Octopus.Simulator.Networks
[SerializeField]
string MQTTpath = "";
MQTTClient client;
public bool isSceneReroad = false;
public event Action onLogicUpdated;
bool flag = true;
// Start is called once before the first execution of Update after the MonoBehaviour is created
@@ -82,6 +83,15 @@ namespace Octopus.Simulator.Networks
public void Connect(string clientName, string host, int port)
{
if(client != null)
{
flag = true;
clientTable.Remove(clientName);
client.OnConnected -= ((client) => OnConnected(client,clientName));
client.OnStateChanged -= OnStateChange;
client.OnDisconnect -= OnDisconnected;
client.OnError -= OnError;
}
client = new MQTTClientBuilder()
.WithOptions(new ConnectionOptionsBuilder().WithWebSocket(host,port).WithPath("/mqtt").WithTLS())
.WithEventHandler(client => OnConnected(client, clientName))
@@ -96,6 +106,8 @@ namespace Octopus.Simulator.Networks
public event Action<MQTTClient> onConnected;
private void OnConnected(MQTTClient client, string clientName)
{
Debug.Log("연결완료");
clientTable.Add(clientName, client);
onConnected?.Invoke(client);
@@ -136,12 +148,23 @@ namespace Octopus.Simulator.Networks
}
}
private void OnDisconnected(MQTTClient client, DisconnectReasonCodes reasonCode, string reasonMessage)
private async void OnDisconnected(MQTTClient client, DisconnectReasonCodes reasonCode, string reasonMessage)
{
//Debug.Log(reasonMessage);
if(isSceneReroad)
{
isSceneReroad = false;
return;
}
//throw new NotImplementedException();
if (Application.isPlaying)
{
var reconnect = await AlertManager.I.ShowConfirm("MQTT 연결 실패", "네트워크 재연결 하시겠습니까?");
if(reconnect)
SetMqttConfig();
}
}
private void OnStateChange(MQTTClient client, ClientStates oldState, ClientStates newState)
{

View File

@@ -53,6 +53,7 @@ MonoBehaviour:
component_id:
distributer: {fileID: 0}
MQTTpath: MQTTConfig
isSceneReroad: 0
--- !u!114 &8164125700257988699
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -184,6 +185,7 @@ Transform:
m_Children:
- {fileID: 4142352401407858928}
- {fileID: 3645010147275428242}
- {fileID: 1423451384795958701}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &4739726380097546759
@@ -274,3 +276,47 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
product: {fileID: 3554305899873773484, guid: a0607d71a04b3f4459be2d9646fcb429, type: 3}
--- !u!1 &8662603362806828459
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1423451384795958701}
- component: {fileID: 7260258999433564145}
m_Layer: 0
m_Name: AlertManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1423451384795958701
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8662603362806828459}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5366961481726599031}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7260258999433564145
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8662603362806828459}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 210ab3bedc01a564089219c90ecc3e5b, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections.Generic;
@@ -6,6 +6,8 @@ using Octopus.Simulator.Networks;
using Newtonsoft.Json;
using TMPro;
using UVC.Networks;
using Best.MQTT;
using Best.MQTT.Packets;
namespace Octopus.Simulator
{
@@ -25,7 +27,6 @@ namespace Octopus.Simulator
public bool isplaying = false;
public event Action<bool> onPlaying;
bool isCreate = false;
public event Action onLogicBTNClicked;
Popup_Reset popupReset;
@@ -51,6 +52,7 @@ namespace Octopus.Simulator
Button_Reset.onClick.AddListener(OnClickReset);
Button_Complete.onClick.AddListener(OnClickCompleteBTN);
popupReset = FindAnyObjectByType<Popup_Reset>(FindObjectsInactive.Include);
MQTTManager.mqttManager.onConnected += ReConnect;
}
void OnClickPlayBTN()
@@ -123,9 +125,7 @@ namespace Octopus.Simulator
param.parameters.real_time = true;
param.parameters.speed = WebParameters.speed;
string requestAPI = $"{webmanager.apiConfig.history}/{WebParameters.id}/start";
webmanager.Reqeust<UpdatedSimulationsInfo>(requestAPI, RequestType.POST, null, param);
//webmanager.Request_Post(param, requestAPI, (flag, value) =>
//{
// if (flag)
@@ -204,6 +204,20 @@ namespace Octopus.Simulator
var reqeustURL = $"{webmanager.apiConfig.history}/{WebParameters.id}/resume";
emptyClass ec = new emptyClass();
webmanager.Reqeust<emptyClass>(reqeustURL, RequestType.POST,null,ec);
Application.ExternalCall("setCamAngle", "Test");
}
//MQTT 재연결
private void ReConnect(MQTTClient client)
{
if(isplaying)
SetMqttConnect();
else
{
if (string.IsNullOrEmpty(WebParameters.code))
return;
MQTTManager.mqttManager.SubscribeTopic($"simulation/{WebParameters.code}/#");
}
}
public void OnClickReset()

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using UnityEngine;
using System;
@@ -46,5 +46,10 @@ namespace Octopus.Simulator.Networks
onWebConfigReceived?.Invoke(json);
Debug.Log($"webconfig:{json}");
}
public void cameAngle(string angle)
{
Debug.Log($"webCam:{angle}");
}
}
}

View File

@@ -0,0 +1,68 @@
using Cysharp.Threading.Tasks;
using UnityEngine;
public class AlertManager : UnitySingleton<AlertManager>
{
private GameObject prefab;
private UIAlert alert;
private void Create()
{
if (alert == null)
{
if (prefab == null)
{
prefab = Resources.Load("UIPrefab/UIAlert", typeof(GameObject)) as GameObject;
}
GameObject go = UnityEngine.Object.Instantiate(prefab);
alert = go.GetComponent<UIAlert>();
}
var canvas = FindAnyObjectByType<Canvas_Main>();
alert.transform.SetParent(canvas.transform, false);
}
public async UniTask ShowAlert(string title, string message, string okButtonTitle = "OK")
{
Create();
bool isClosed = false;
alert.Init(title: title, message: message, okButtonText: okButtonTitle, showCancelButton: false);
alert.OnOk.AddListener(() =>
{
isClosed = true;
});
alert.Open();
await UniTask.WaitUntil(() => isClosed == true);
}
public async UniTask<bool> ShowConfirm(string title, string message, string okButtonTitle = "OK", string cancelButtonTitle = "CANCEL")
{
Create();
bool isClosed = false;
bool result = false;
alert.Init(title, message, okButtonTitle, cancelButtonTitle, true);
alert.OnOk.AddListener(() =>
{
result = true;
isClosed = true;
});
alert.OnCancel.AddListener(() =>
{
result = false;
isClosed = true;
});
alert.Open();
await UniTask.WaitUntil(() => isClosed == true);
return result;
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace Assets.WorkSpace.R
{
[Serializable]
public class CameraEntity
{
public string posX;
public string posY;
public string posZ;
public string rotX;
public string rotY;
public string rotZ;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d4042e1f19d2fd140b4fbd63d08a55bc