diff --git a/Assets/Prefabs/UIRIghtItem/LogicDataPrefab.prefab b/Assets/Prefabs/UIRIghtItem/LogicDataPrefab.prefab index fa4b0d48..85542169 100644 --- a/Assets/Prefabs/UIRIghtItem/LogicDataPrefab.prefab +++ b/Assets/Prefabs/UIRIghtItem/LogicDataPrefab.prefab @@ -51,8 +51,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7b5367f9feadcb94f922ceeb148ff63d, type: 3} m_Name: m_EditorClassIdentifier: - text_Label: {fileID: 836481912262468791} - text_Value: {fileID: 8842226809247879340} + Text_Label: {fileID: 836481912262468791} + Text_Value: {fileID: 8842226809247879340} --- !u!222 &4086929857223959196 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Simulation_0.0.1.unity b/Assets/Scenes/Simulation_0.0.1.unity index 71fc948d..66eff59a 100644 --- a/Assets/Scenes/Simulation_0.0.1.unity +++ b/Assets/Scenes/Simulation_0.0.1.unity @@ -5955,6 +5955,10 @@ PrefabInstance: 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 @@ -6011,6 +6015,14 @@ PrefabInstance: propertyPath: LogicContent value: objectReference: {fileID: 384003842} + - 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: [] diff --git a/Assets/Scripts/SimulationModels/SimulationModelConveyor.cs b/Assets/Scripts/SimulationModels/SimulationModelConveyor.cs index 2ede5cf8..1dad8f09 100644 --- a/Assets/Scripts/SimulationModels/SimulationModelConveyor.cs +++ b/Assets/Scripts/SimulationModels/SimulationModelConveyor.cs @@ -5,9 +5,7 @@ using UnityEngine; using System.Collections; using Newtonsoft.Json.Linq; using System.Collections.Concurrent; -using RTG; -using Unity.VisualScripting; -using Best.HTTP.JSON; +using Octopus.Simulator.Networks; public class SimulationModelConveyor : SimulationModel { diff --git a/Assets/Scripts/SimulationModels/SimulationModelMove.cs b/Assets/Scripts/SimulationModels/SimulationModelMove.cs index 68033639..ae78d334 100644 --- a/Assets/Scripts/SimulationModels/SimulationModelMove.cs +++ b/Assets/Scripts/SimulationModels/SimulationModelMove.cs @@ -3,8 +3,9 @@ using UnityEngine; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; -using Unity.VisualScripting; using UnityEngine.Events; +using Octopus.Simulator.Networks; + public class SimulationModelMove : SimulationModel { public string eventLoading = "transporter_loading"; diff --git a/Assets/Scripts/SimulationModels/SimulationModelProcess.cs b/Assets/Scripts/SimulationModels/SimulationModelProcess.cs index 3d7cb216..faceed72 100644 --- a/Assets/Scripts/SimulationModels/SimulationModelProcess.cs +++ b/Assets/Scripts/SimulationModels/SimulationModelProcess.cs @@ -4,6 +4,8 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using UnityEngine.Events; +using Octopus.Simulator.Networks; + public class SimulationModelProcess : SimulationModel { public string eventUsingQueue = "processor_using_queue"; diff --git a/Assets/Scripts/SimulationModels/SimulationModelSink.cs b/Assets/Scripts/SimulationModels/SimulationModelSink.cs index 81cfa476..b28355bc 100644 --- a/Assets/Scripts/SimulationModels/SimulationModelSink.cs +++ b/Assets/Scripts/SimulationModels/SimulationModelSink.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json.Linq; using System.Collections.Concurrent; using UnityEngine; using System.Collections; +using Octopus.Simulator.Networks; public class SimulationModelSink : SimulationModel { diff --git a/Assets/Scripts/SimulationModels/SimulationModelSource.cs b/Assets/Scripts/SimulationModels/SimulationModelSource.cs index 4747dfdd..77790902 100644 --- a/Assets/Scripts/SimulationModels/SimulationModelSource.cs +++ b/Assets/Scripts/SimulationModels/SimulationModelSource.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; using System.Collections; using Newtonsoft.Json.Linq; -using Best.HTTP.JSON; +using Octopus.Simulator.Networks; public class SimulationModelSource : SimulationModel { diff --git a/Assets/WorkSpace/LH/LogicData/LogicDataInfoItem.cs b/Assets/WorkSpace/LH/LogicData/LogicDataInfoItem.cs index b59a20fb..bb83027d 100644 --- a/Assets/WorkSpace/LH/LogicData/LogicDataInfoItem.cs +++ b/Assets/WorkSpace/LH/LogicData/LogicDataInfoItem.cs @@ -6,14 +6,14 @@ namespace Octopus.Simulator public class LogicDataInfoItem : MonoBehaviour { [SerializeField] - TMP_Text text_Label; + TMP_Text Text_Label; [SerializeField] - TMP_Text text_Value; + TMP_Text Text_Value; public void Set(string label, string value) { - text_Label.text = label; - text_Value.text = value; + Text_Label.text = label; + Text_Value.text = value; } } } \ No newline at end of file diff --git a/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs b/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs index 9271639d..bb194054 100644 --- a/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs +++ b/Assets/WorkSpace/LH/LogicData/LogicDataManager.cs @@ -2,6 +2,7 @@ using UnityEngine; using System; using System.Collections.Generic; using Octopus.Simulator.Networks; +using UVC.Networks; using Newtonsoft.Json; using UnityEngine.UI; using System.Collections; @@ -27,35 +28,14 @@ namespace Octopus.Simulator public Dictionary dataMap = new Dictionary(); public Dictionary idMap = new Dictionary(); - Panel_LogicData panelLogicData; - Panel_ConnectedObject panelConnectedObject; - Panel_PlacedObject panelPlacedObject; public event Action onLogicButtonClicked; public event Action onLogicDeSelected; - - private void Awake() - { - panelLogicData = FindAnyObjectByType(); - panelConnectedObject = FindAnyObjectByType(); - panelPlacedObject = FindAnyObjectByType(); - } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { - onLogicButtonClicked += panelLogicData.OnLogicDataSelected; - onLogicButtonClicked += panelConnectedObject.OnLogicDataSelected; - onLogicButtonClicked += panelPlacedObject.OnLogicDataSelected; - onLogicDeSelected += panelLogicData.DataDeSelected; - onLogicDeSelected += panelConnectedObject.DataDeSelected; - onLogicDeSelected += panelPlacedObject.DataDeSelected; backGround.onClick.AddListener(() => onLogicDeSelected?.Invoke()); - panelPlacedObject.onPlacedObjectSelected += panelConnectedObject.OnLogicDataSelected; FindAnyObjectByType().onLogicBTNClicked += SetActive; - panelLogicData.gameObject.SetActive(false); - panelConnectedObject.gameObject.SetActive(false); - panelPlacedObject.gameObject.SetActive(false); - //LogicWindow.gameObject.SetActive(false); FindAnyObjectByType().onParameterRecived += RequestInfo; FindAnyObjectByType().onLogicUpdated += RequestInfo; } @@ -80,7 +60,7 @@ namespace Octopus.Simulator public void RequestInfo() { ClearLogicBTN(); - WebManager.webManager.Request_Get($"{WebManager.webManager.apiConfig.logic}/{WebParameters.config.logicId}", (flag, value) => + WebManager.Instance.Request_Get($"{WebManager.Instance.apiConfig.logic}/{WebParameters.config.logicId}", (flag, value) => { if (flag) { diff --git a/Assets/WorkSpace/LH/LogicData/LogicItemButton.cs b/Assets/WorkSpace/LH/LogicData/LogicItemButton.cs index d4526cf1..44765f1c 100644 --- a/Assets/WorkSpace/LH/LogicData/LogicItemButton.cs +++ b/Assets/WorkSpace/LH/LogicData/LogicItemButton.cs @@ -1,40 +1,41 @@ -using Octopus.Simulator; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; -public class LogicItemButton : MonoBehaviour +namespace Octopus.Simulator { - [Header("UI References")] - [SerializeField] private Image iconImage; - [SerializeField] private TMP_Text nameText; - [SerializeField] private Button button; - - [Header("Type Icons")] - [SerializeField] private Sprite resourceIcon; - [SerializeField] private Sprite storeIcon; - [SerializeField] private Sprite queueIcon; - [SerializeField] private Sprite productGeneratorIcon; - [SerializeField] private Sprite processorIcon; - [SerializeField] private Sprite transporterIcon; - [SerializeField] private Sprite shipmentIcon; - - // Ÿԡ - private Dictionary IconMap; - private Dictionary componentMap; - /// - /// ܺο ư ʱȭ ȣ - /// - public void Setup(ILogicItem item) + public class LogicItemButton : MonoBehaviour { - IconMap = new Dictionary() + [Header("UI References")] + [SerializeField] private Image iconImage; + [SerializeField] private TMP_Text nameText; + [SerializeField] private Button button; + + [Header("Type Icons")] + [SerializeField] private Sprite resourceIcon; + [SerializeField] private Sprite storeIcon; + [SerializeField] private Sprite queueIcon; + [SerializeField] private Sprite productGeneratorIcon; + [SerializeField] private Sprite processorIcon; + [SerializeField] private Sprite transporterIcon; + [SerializeField] private Sprite shipmentIcon; + + // Ÿԡ + private Dictionary IconMap; + private Dictionary componentMap; + /// + /// ܺο ư ʱȭ ȣ + /// + public void Setup(ILogicItem item) + { + IconMap = new Dictionary() { { LogicItemType.Queue, queueIcon }, { LogicItemType.Resource, resourceIcon }, {LogicItemType.Store,storeIcon } }; - componentMap = new Dictionary() + componentMap = new Dictionary() { { ComponentType.Product_Generator,productGeneratorIcon }, { ComponentType.Processor,processorIcon }, @@ -44,14 +45,15 @@ public class LogicItemButton : MonoBehaviour }; - if (item.ItemType != LogicItemType.Component) - { - iconImage.sprite = IconMap[item.ItemType]; + if (item.ItemType != LogicItemType.Component) + { + iconImage.sprite = IconMap[item.ItemType]; + } + else + { + iconImage.sprite = componentMap[(item as ILogicComponent).Type]; + } + nameText.text = item.Label; } - else - { - iconImage.sprite = componentMap[(item as ILogicComponent).Type]; - } - nameText.text = item.Label; } } \ No newline at end of file diff --git a/Assets/WorkSpace/LH/LogicData/LogicPlacedObjectButton.cs b/Assets/WorkSpace/LH/LogicData/LogicPlacedObjectButton.cs deleted file mode 100644 index 62ed50fc..00000000 --- a/Assets/WorkSpace/LH/LogicData/LogicPlacedObjectButton.cs +++ /dev/null @@ -1,17 +0,0 @@ -using UnityEngine; -using Octopus.Simulator; -using TMPro; - -namespace Octopus.Simulator -{ - public class LogicPlacedObjectButton : MonoBehaviour - { - [SerializeField] - TMP_Text text_Label; - - public void Set(string name) - { - text_Label.text = name; - } - } -} \ No newline at end of file diff --git a/Assets/WorkSpace/LH/LogicData/LogicPlacedObjectButton.cs.meta b/Assets/WorkSpace/LH/LogicData/LogicPlacedObjectButton.cs.meta deleted file mode 100644 index 7f949217..00000000 --- a/Assets/WorkSpace/LH/LogicData/LogicPlacedObjectButton.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: fcb433a8a5a1cb9499b04771da71feda \ No newline at end of file diff --git a/Assets/WorkSpace/LH/LogicData/ObjectPopup.cs b/Assets/WorkSpace/LH/LogicData/ObjectPopup.cs deleted file mode 100644 index c978937d..00000000 --- a/Assets/WorkSpace/LH/LogicData/ObjectPopup.cs +++ /dev/null @@ -1,14 +0,0 @@ -using UnityEngine; -using TMPro; - -public class ObjectPopup : MonoBehaviour -{ - public TMP_Text label; - public TMP_Text data; - - public void Set(string label,string data) - { - this.label.text = label; - this.data.text = data; - } -} diff --git a/Assets/WorkSpace/LH/LogicData/ObjectPopup.cs.meta b/Assets/WorkSpace/LH/LogicData/ObjectPopup.cs.meta deleted file mode 100644 index 7358abc8..00000000 --- a/Assets/WorkSpace/LH/LogicData/ObjectPopup.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 11558110f89df71498fc76c786f4dd9f \ No newline at end of file diff --git a/Assets/WorkSpace/LH/LogicData/Panel_ConnectedObject.cs b/Assets/WorkSpace/LH/LogicData/Panel_ConnectedObject.cs index 520f50d7..3da2a8f3 100644 --- a/Assets/WorkSpace/LH/LogicData/Panel_ConnectedObject.cs +++ b/Assets/WorkSpace/LH/LogicData/Panel_ConnectedObject.cs @@ -19,12 +19,22 @@ namespace Octopus.Simulator { "ġ","" }, { "ID","" } }; + + float panelPadding = 25f; // Start is called once before the first execution of Update after the MonoBehaviour is created void Awake() { rect = GetComponent(); } + private void Start() + { + var logicDataManager = FindAnyObjectByType(); + logicDataManager.onLogicButtonClicked += SetLogicDataItem; + logicDataManager.onLogicDeSelected += UnsetConnectedDataItem; + gameObject.SetActive(false); + } + void ClearItem() { foreach (var infoItem in infoItems) @@ -51,15 +61,14 @@ namespace Octopus.Simulator } } - public void OnLogicDataSelected(ILogicItem item) + public void SetLogicDataItem(ILogicItem item) { gameObject.SetActive(true); ClearItem(); GetObjectByName(item.Name); float itemHeight = logicItem.GetComponent().rect.height; - float panelHeight = dataMap.Count * itemHeight+25f; - rect.sizeDelta = new Vector2(rect.sizeDelta.x, panelHeight); + SetRectHeight(itemHeight); int i = 0; foreach (var p in dataMap) { @@ -74,15 +83,14 @@ namespace Octopus.Simulator LayoutRebuilder.ForceRebuildLayoutImmediate(contentRect); } - public void OnLogicDataSelected(string itemName) + public void SetConnectedDataItem(string itemName) { gameObject.SetActive(true); ClearItem(); GetObjectByName(itemName); float itemHeight = logicItem.GetComponent().rect.height; - float panelHeight = dataMap.Count * itemHeight+25f; - rect.sizeDelta = new Vector2(rect.sizeDelta.x, panelHeight); + SetRectHeight(itemHeight); int i = 0; foreach (var p in dataMap) { @@ -97,7 +105,13 @@ namespace Octopus.Simulator LayoutRebuilder.ForceRebuildLayoutImmediate(contentRect); } - public void DataDeSelected() + void SetRectHeight(float itemHeight) + { + float panelHeight = dataMap.Count * itemHeight + panelPadding; + rect.sizeDelta = new Vector2(rect.sizeDelta.x, panelHeight); + } + + public void UnsetConnectedDataItem() { gameObject.SetActive(false); } diff --git a/Assets/WorkSpace/LH/LogicData/Panel_LogicData.cs b/Assets/WorkSpace/LH/LogicData/Panel_LogicData.cs index f10496df..ec8508fa 100644 --- a/Assets/WorkSpace/LH/LogicData/Panel_LogicData.cs +++ b/Assets/WorkSpace/LH/LogicData/Panel_LogicData.cs @@ -14,12 +14,22 @@ namespace Octopus.Simulator RectTransform rect; [SerializeField] RectTransform contentRect; + + float panelPadding = 25f; // Start is called once before the first execution of Update after the MonoBehaviour is created private void Awake() { rect = GetComponent(); } + private void Start() + { + var logicDataManager = FindAnyObjectByType(); + logicDataManager.onLogicButtonClicked += SetLogicDataItem; + logicDataManager.onLogicDeSelected += UnsetLogicDataItem; + gameObject.SetActive(false); + } + void ClearItem() { foreach (var infoItem in infoItems) @@ -29,7 +39,7 @@ namespace Octopus.Simulator infoItems.Clear(); } - public void OnLogicDataSelected(ILogicItem item) + public void SetLogicDataItem(ILogicItem item) { gameObject.SetActive(true); ClearItem(); @@ -49,8 +59,7 @@ namespace Octopus.Simulator } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); float itemHeight = logicItem.GetComponent().rect.height; - float panelHeight = fields.Length * itemHeight+25f; - rect.sizeDelta = new Vector2(rect.sizeDelta.x, panelHeight); + SetRectHeight(fields.Length, itemHeight); for (int i = 0; i < fields.Length; i++) { var rawValue = fields[i].GetValue(item); @@ -63,7 +72,13 @@ namespace Octopus.Simulator LayoutRebuilder.ForceRebuildLayoutImmediate(contentRect); } - public void DataDeSelected() + void SetRectHeight(int count,float itemHeight) + { + float panelHeight = count * itemHeight + panelPadding; + rect.sizeDelta = new Vector2(rect.sizeDelta.x, panelHeight); + } + + public void UnsetLogicDataItem() { gameObject.SetActive(false); } diff --git a/Assets/WorkSpace/LH/LogicData/Panel_PlacedObject.cs b/Assets/WorkSpace/LH/LogicData/Panel_PlacedObject.cs index ba1008d9..f5afc807 100644 --- a/Assets/WorkSpace/LH/LogicData/Panel_PlacedObject.cs +++ b/Assets/WorkSpace/LH/LogicData/Panel_PlacedObject.cs @@ -8,10 +8,8 @@ namespace Octopus.Simulator { public class Panel_PlacedObject : MonoBehaviour { - List