refactoring0605
This commit is contained in:
@@ -119,11 +119,34 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &58003261 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2222743492580726404, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
|
||||
m_PrefabInstance: {fileID: 6579092525594939345}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!224 &80690333 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 3202402725712308353, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
|
||||
m_PrefabInstance: {fileID: 6579092525594939345}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &80690334
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 58003261}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: db23f43a626977e499745e70cceaae33, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
UIPrefabPath: UIPrefab
|
||||
logicWindow: {fileID: 58003261}
|
||||
LogicPrefab: {fileID: 2210399282865539074, guid: 72314043a41090846a8c16ad04f3c028, type: 3}
|
||||
LinePrefab: {fileID: 6254276411767355245, guid: c899c98324602eb4fbe900753508f64d, type: 3}
|
||||
logicContent: {fileID: 384003842}
|
||||
backGround: {fileID: 1351749705}
|
||||
--- !u!1001 &113814761
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -5024,17 +5047,6 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1216065597}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1237304820 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 4739726380097546759, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
m_PrefabInstance: {fileID: 594906197750746389}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 766d9cdfba5257c4b9beedbfbc5f5d4a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1251266449
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -5947,18 +5959,10 @@ PrefabInstance:
|
||||
propertyPath: menuPanel
|
||||
value:
|
||||
objectReference: {fileID: 518271856}
|
||||
- target: {fileID: 3408166986665272114, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: webReceiver
|
||||
value:
|
||||
objectReference: {fileID: 1237304820}
|
||||
- target: {fileID: 3408166986665272114, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: projectMenuButton
|
||||
value:
|
||||
objectReference: {fileID: 205755441}
|
||||
- target: {fileID: 4739726380097546759, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5366961481726599031, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -1.2462957
|
||||
@@ -6007,26 +6011,10 @@ PrefabInstance:
|
||||
propertyPath: LogicWindow
|
||||
value:
|
||||
objectReference: {fileID: 80690333}
|
||||
- target: {fileID: 6191105916327120908, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: webReceiver
|
||||
value:
|
||||
objectReference: {fileID: 1237304820}
|
||||
- target: {fileID: 6191105916327120908, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: LogicContent
|
||||
value:
|
||||
objectReference: {fileID: 384003842}
|
||||
- target: {fileID: 6191105916327120908, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: UIPrefabPath
|
||||
value: UIPrefab
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8164125700257988699, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: _apiConfigResourcePath
|
||||
value: APIEndPointsConfig
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8164125700257988699, guid: 6c1ed824d30fe8848957d865919227a0, type: 3}
|
||||
propertyPath: _webConfigResourcePath
|
||||
value: WebConfig
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@@ -6620,7 +6608,10 @@ PrefabInstance:
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 2222743492580726404, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 80690334}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: ea4abd0239cb35e47914f9614cf08d69, type: 3}
|
||||
--- !u!1001 &6890256579638460283
|
||||
PrefabInstance:
|
||||
@@ -6896,7 +6887,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8289542207162785557, guid: 461675fb4e57d014f90cc1f743049f29, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: ObjectStatus_ver2
|
||||
value: LogicStatus
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
|
||||
@@ -13,61 +13,24 @@ namespace Octopus.Simulator
|
||||
{
|
||||
public LogicData currentData;
|
||||
public LogicWebConfig config;
|
||||
[SerializeField]
|
||||
string UIPrefabPath = "UIPrefab";
|
||||
Button LogicPrefab;
|
||||
Image LinePrefab;
|
||||
[SerializeField]
|
||||
RectTransform LogicWindow;
|
||||
[SerializeField]
|
||||
RectTransform LogicContent;
|
||||
[SerializeField]
|
||||
Button backGround;
|
||||
|
||||
public Dictionary<Button, ILogicItem> logicButtonDict = new Dictionary<Button, ILogicItem>();
|
||||
public Dictionary<string, Button> idMap = new Dictionary<string, Button>();
|
||||
public event Action<LogicData> onLogicUpdated;
|
||||
|
||||
public event Action<ILogicItem> onLogicButtonClicked;
|
||||
public event Action onLogicDeSelected;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
LogicPrefab = Resources.Load<Button>($"{UIPrefabPath}/{nameof(LogicPrefab)}");
|
||||
LinePrefab = Resources.Load<Image>($"{UIPrefabPath}/{nameof(LinePrefab)}");
|
||||
}
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
backGround.onClick.AddListener(() => onLogicDeSelected?.Invoke());
|
||||
FindAnyObjectByType<Panel_SimulationUI>().onLogicBTNClicked += SetActive;
|
||||
FindAnyObjectByType<WebReceiver>().onParameterRecived += RequestInfo;
|
||||
FindAnyObjectByType<MQTTManager>().onLogicUpdated += RequestInfo;
|
||||
}
|
||||
|
||||
void ClearLogicBTN()
|
||||
{
|
||||
foreach (var pair in logicButtonDict)
|
||||
{
|
||||
Destroy(pair.Key.gameObject);
|
||||
}
|
||||
logicButtonDict.Clear();
|
||||
idMap.Clear();
|
||||
}
|
||||
|
||||
void SetActive()
|
||||
{
|
||||
LogicWindow.gameObject.SetActive(!LogicWindow.gameObject.activeSelf);
|
||||
onLogicDeSelected?.Invoke();
|
||||
}
|
||||
|
||||
public void RequestInfo()
|
||||
{
|
||||
ClearLogicBTN();
|
||||
WebManager.Instance.Request_Get($"{WebManager.Instance.apiConfig.logic}/{WebParameters.config.logicId}", (flag, value) =>
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
var info = JsonConvert.DeserializeObject<LogicInfo>(value);
|
||||
onLogicUpdated?.Invoke(info.data);
|
||||
GetDataFromInfo(info.data);
|
||||
}
|
||||
});
|
||||
@@ -87,89 +50,6 @@ namespace Octopus.Simulator
|
||||
saveload.Onclick_Load(files.data.info);
|
||||
}
|
||||
}
|
||||
QueueVisualization(Data.data.queues);
|
||||
ResourceVisualization(Data.data.resources);
|
||||
StoreVisualization(Data.data.stores);
|
||||
ComponentVisualization(Data.data.components);
|
||||
ConnectEdge();
|
||||
}
|
||||
|
||||
void QueueVisualization(List<LogicQueue> queues)
|
||||
{
|
||||
idMap.Clear();
|
||||
|
||||
foreach (var queue in queues)
|
||||
{
|
||||
var logicButton = Instantiate(LogicPrefab, LogicContent);
|
||||
var item = logicButton.GetComponent<LogicItemButton>();
|
||||
item.Setup(queue);
|
||||
logicButtonDict.Add(logicButton, queue);
|
||||
idMap.Add(config.nodes.Find(n => n.data.name == queue.name).id, logicButton);
|
||||
logicButton.onClick.AddListener(() => OnLogicButtonClick(queue));
|
||||
logicButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(config.nodes.Find(n => n.data.name==queue.name).position.x, -config.nodes.Find(n => n.data.name == queue.name).position.y);
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceVisualization(List<LogicResource> resources)
|
||||
{
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
var logicButton = Instantiate(LogicPrefab, LogicContent);
|
||||
var item = logicButton.GetComponent<LogicItemButton>();
|
||||
item.Setup(resource);
|
||||
logicButtonDict.Add(logicButton, resource);
|
||||
idMap.Add(config.nodes.Find(n => n.data.name == resource.name).id, logicButton);
|
||||
logicButton.onClick.AddListener(() => OnLogicButtonClick(resource));
|
||||
logicButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(config.nodes.Find(n => n.data.name == resource.name).position.x, -config.nodes.Find(n => n.data.name == resource.name).position.y);
|
||||
}
|
||||
}
|
||||
|
||||
void StoreVisualization(List<LogicStore> stores)
|
||||
{
|
||||
foreach (var store in stores)
|
||||
{
|
||||
var logicButton = Instantiate(LogicPrefab, LogicContent);
|
||||
var item = logicButton.GetComponent<LogicItemButton>();
|
||||
item.Setup(store);
|
||||
logicButtonDict.Add(logicButton, store);
|
||||
idMap.Add(config.nodes.Find(n => n.data.name == store.name).id, logicButton);
|
||||
logicButton.onClick.AddListener(() => OnLogicButtonClick(store));
|
||||
logicButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(config.nodes.Find(n => n.data.name == store.name).position.x, -config.nodes.Find(n => n.data.name == store.name).position.y);
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentVisualization(List<ILogicComponent> components)
|
||||
{
|
||||
foreach (var component in components)
|
||||
{
|
||||
var logicButton = Instantiate(LogicPrefab, LogicContent);
|
||||
var item = logicButton.GetComponent<LogicItemButton>();
|
||||
item.Setup(component);
|
||||
logicButtonDict.Add(logicButton, component);
|
||||
idMap.Add(config.nodes.Find(n => n.data.name == component.Name).id, logicButton);
|
||||
logicButton.onClick.AddListener(() => OnLogicButtonClick(component));
|
||||
logicButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(config.nodes.Find(n => n.data.name == component.Name).position.x, -config.nodes.Find(n => n.data.name == component.Name).position.y);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectEdge()
|
||||
{
|
||||
foreach(var edge in config.edges)
|
||||
{
|
||||
var line=Instantiate(LinePrefab, LogicContent);
|
||||
line.transform.SetAsFirstSibling();
|
||||
line.rectTransform.anchoredPosition = (idMap[edge.source].GetComponent<RectTransform>().anchoredPosition+ idMap[edge.target].GetComponent<RectTransform>().anchoredPosition)/2f;
|
||||
Vector2 direction = idMap[edge.target].GetComponent<RectTransform>().anchoredPosition - idMap[edge.source].GetComponent<RectTransform>().anchoredPosition;
|
||||
float length = direction.magnitude;
|
||||
line.rectTransform.sizeDelta = new Vector2(length,line.rectTransform.sizeDelta.y);
|
||||
float angleRad = Mathf.Atan2(direction.y, direction.x)*Mathf.Rad2Deg; // ¶óµð¾È
|
||||
line.transform.rotation = Quaternion.Euler(0, 0, angleRad);
|
||||
}
|
||||
}
|
||||
|
||||
void OnLogicButtonClick(ILogicItem item)
|
||||
{
|
||||
onLogicButtonClicked?.Invoke(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,34 @@ namespace Octopus.Simulator
|
||||
{
|
||||
public class LogicUIManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject logicWindow; // 전체 윈도우 패널
|
||||
[SerializeField] private Button LogicPrefab; // Logic 아이템 버튼 프리팹
|
||||
[SerializeField] private Image LinePrefab; // 노드를 연결하는 라인 프리팹
|
||||
[SerializeField] private RectTransform logicContent; // 버튼·라인을 배치할 부모 컨테이너
|
||||
[SerializeField]
|
||||
string UIPrefabPath = "UIPrefab";
|
||||
|
||||
public event Action<ILogicItem> OnLogicItemClicked;
|
||||
private Dictionary<string, Button> idMap;
|
||||
[SerializeField]
|
||||
GameObject logicWindow;
|
||||
[SerializeField]
|
||||
Button LogicPrefab;
|
||||
[SerializeField]
|
||||
Image LinePrefab;
|
||||
[SerializeField]
|
||||
RectTransform logicContent;
|
||||
[SerializeField]
|
||||
Button backGround;
|
||||
|
||||
public event Action<ILogicItem> onLogicItemSelected;
|
||||
public event Action onLogicItemDeSelected;
|
||||
private Dictionary<string, Button> idMap=new Dictionary<string, Button>();
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
private void Awake()
|
||||
{
|
||||
LogicPrefab = Resources.Load<Button>($"{UIPrefabPath}/{nameof(LogicPrefab)}");
|
||||
LinePrefab = Resources.Load<Image>($"{UIPrefabPath}/{nameof(LinePrefab)}");
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
//FindAnyObjectByType<LogicDataManager>().on
|
||||
backGround.onClick.AddListener(() => onLogicItemDeSelected?.Invoke());
|
||||
FindAnyObjectByType<LogicDataManager>().onLogicUpdated += BuildLogicUI;
|
||||
FindAnyObjectByType<Panel_SimulationUI>().onLogicBTNClicked += SetActive;
|
||||
}
|
||||
public void BuildLogicUI(LogicData data)
|
||||
{
|
||||
@@ -27,15 +44,12 @@ namespace Octopus.Simulator
|
||||
ConnectEdge(data.webConfig);
|
||||
}
|
||||
|
||||
public void ShowLogicWindow()
|
||||
public void SetActive()
|
||||
{
|
||||
logicWindow.SetActive(true);
|
||||
logicWindow.gameObject.SetActive(!logicWindow.gameObject.activeSelf);
|
||||
onLogicItemDeSelected?.Invoke();
|
||||
}
|
||||
|
||||
public void HideLogicWindow()
|
||||
{
|
||||
logicWindow.SetActive(false);
|
||||
}
|
||||
private void ClearExistingUI()
|
||||
{
|
||||
// logicContent 하위의 모든 버튼 및 라인 오브젝트를 제거
|
||||
@@ -133,7 +147,7 @@ namespace Octopus.Simulator
|
||||
|
||||
void OnLogicButtonClick(ILogicItem item)
|
||||
{
|
||||
OnLogicItemClicked?.Invoke(item);
|
||||
onLogicItemSelected?.Invoke(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,9 @@ namespace Octopus.Simulator
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var logicDataManager = FindAnyObjectByType<LogicDataManager>();
|
||||
logicDataManager.onLogicButtonClicked += SetLogicDataItem;
|
||||
logicDataManager.onLogicDeSelected += UnsetConnectedDataItem;
|
||||
var logicUIManager = FindAnyObjectByType<LogicUIManager>();
|
||||
logicUIManager.onLogicItemSelected += SetLogicDataItem;
|
||||
logicUIManager.onLogicItemDeSelected += UnsetConnectedDataItem;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace Octopus.Simulator
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var logicDataManager = FindAnyObjectByType<LogicDataManager>();
|
||||
logicDataManager.onLogicButtonClicked += SetLogicDataItem;
|
||||
logicDataManager.onLogicDeSelected += UnsetLogicDataItem;
|
||||
var logicUIManager = FindAnyObjectByType<LogicUIManager>();
|
||||
logicUIManager.onLogicItemSelected += SetLogicDataItem;
|
||||
logicUIManager.onLogicItemDeSelected += UnsetLogicDataItem;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace Octopus.Simulator
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var logicDataManager = FindAnyObjectByType<LogicDataManager>();
|
||||
logicDataManager.onLogicButtonClicked += SetPlacedObjectDataItem;
|
||||
logicDataManager.onLogicDeSelected += UnsetPlacedObjectDataItem;
|
||||
var logicUIManager = FindAnyObjectByType<LogicUIManager>();
|
||||
logicUIManager.onLogicItemSelected += SetPlacedObjectDataItem;
|
||||
logicUIManager.onLogicItemDeSelected += UnsetPlacedObjectDataItem;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user