스크립트이동
This commit is contained in:
File diff suppressed because one or more lines are too long
23
Assets/Scripts/Studio/TwinObject/AbstractFunctionObject.cs
Normal file
23
Assets/Scripts/Studio/TwinObject/AbstractFunctionObject.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public enum ObjectType
|
||||
{
|
||||
None,
|
||||
Dynamic,
|
||||
Static
|
||||
}
|
||||
|
||||
public abstract class AbstractFunctionObject : MonoBehaviour
|
||||
{
|
||||
public virtual Dictionary<string, string> Info { get; set; }
|
||||
public virtual Dictionary<string, string> Label { get; set; }
|
||||
|
||||
public virtual ObjectType ObjectType { get; set; }
|
||||
|
||||
public abstract void OnUpdateData(object sender, StudioServiceIdEventArgs e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08be9c7b11ca16a43802b09dcc591a9d
|
||||
8
Assets/Scripts/Studio/UI/Panel_3DDy.meta
Normal file
8
Assets/Scripts/Studio/UI/Panel_3DDy.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6a080ddfc6d49e44a7493846995fc01
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
[CreateAssetMenu(fileName = "AddComponetData", menuName = "Scriptable Objects/AddComponetData")]
|
||||
public class AddComponetDataScriptable : ScriptableObject
|
||||
{
|
||||
public List<AddComponetData> compoenets;
|
||||
|
||||
[ContextMenu("SetItem")]
|
||||
public void SetItem()
|
||||
{
|
||||
//디렉토리 경로 가져오고
|
||||
compoenets.Clear();
|
||||
var allObject = Resources.LoadAll<AbstractFunctionObject>("Prefabs/FunctionObject");
|
||||
foreach(var obj in allObject)
|
||||
{
|
||||
var key = obj.name;
|
||||
var item = new AddComponetData(key, obj);
|
||||
compoenets.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public class AddComponetData
|
||||
{
|
||||
public AddComponetData(string key, Component comp)
|
||||
{
|
||||
this.key = key;
|
||||
this.comp = comp;
|
||||
}
|
||||
public string key;
|
||||
public Component comp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 654aed6b109dc4b4da05e7feaa681bf0
|
||||
58
Assets/Scripts/Studio/UI/Panel_3DDy/AddComponetModal.cs
Normal file
58
Assets/Scripts/Studio/UI/Panel_3DDy/AddComponetModal.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class AddComponetModal : MonoBehaviour
|
||||
{
|
||||
private TextMeshProUGUI Text_Componet;
|
||||
private ConnectionItem connectionItem;
|
||||
private List<string> componetentKeyTable =new();
|
||||
|
||||
public Action<string> onSelectComponet;
|
||||
public void Init()
|
||||
{
|
||||
connectionItem = GetComponentInChildren<ConnectionItem>();
|
||||
connectionItem.Init();
|
||||
|
||||
SetItem();
|
||||
SetConnectionItem();
|
||||
}
|
||||
public void Open()
|
||||
{
|
||||
SetItem();
|
||||
}
|
||||
|
||||
public void ChangeItem(string key)
|
||||
{
|
||||
var index = connectionItem.GetValue(key);
|
||||
connectionItem.AddConnection.SetValueWithoutNotify(index);
|
||||
}
|
||||
|
||||
private void SetConnectionItem()
|
||||
{
|
||||
connectionItem.SetItem(componetentKeyTable);
|
||||
connectionItem.onValueChange = SelectAddComponent;
|
||||
}
|
||||
|
||||
private void SelectAddComponent(string key)
|
||||
{
|
||||
onSelectComponet?.Invoke(key);
|
||||
}
|
||||
|
||||
private void SetItem()
|
||||
{
|
||||
var item = Resources.Load<AddComponetDataScriptable>("Scriptable/AddComponetData");
|
||||
item.SetItem();
|
||||
componetentKeyTable.Clear();
|
||||
componetentKeyTable.Add(string.Empty);
|
||||
foreach (var comp in item.compoenets)
|
||||
{
|
||||
componetentKeyTable.Add(comp.key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cfe3b7d939673e4987cd66a44c8560d
|
||||
49
Assets/Scripts/Studio/UI/Panel_3DDy/ConnectionItem.cs
Normal file
49
Assets/Scripts/Studio/UI/Panel_3DDy/ConnectionItem.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using NUnit.Framework;
|
||||
using Studio.Dynamic.TwinObject;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class ConnectionItem : MonoBehaviour
|
||||
{
|
||||
private Button button;
|
||||
private TMP_Dropdown addConnection;
|
||||
|
||||
public TMP_Dropdown AddConnection { get { return addConnection; } }
|
||||
public Button Button { get { return button; } }
|
||||
|
||||
public Action<string> onValueChange;
|
||||
public void Init()
|
||||
{
|
||||
button = GetComponentInChildren<Button>();
|
||||
addConnection = GetComponentInChildren<TMP_Dropdown>();
|
||||
addConnection.onValueChanged.AddListener(OnSelectDropDownItem);
|
||||
}
|
||||
|
||||
private void OnSelectDropDownItem(int arg0)
|
||||
{
|
||||
var selectItem = addConnection.options[arg0];
|
||||
var result = selectItem.text;
|
||||
onValueChange?.Invoke(result);
|
||||
}
|
||||
|
||||
public int GetValue(string key)
|
||||
{
|
||||
var item = addConnection.options.FirstOrDefault(x => x.text.Equals(key));
|
||||
var value = addConnection.options.IndexOf(item);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void SetItem(List<string> options)
|
||||
{
|
||||
addConnection.ClearOptions();
|
||||
addConnection.AddOptions(options);
|
||||
addConnection.SetValueWithoutNotify(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 215f675b2b4c8ca448046c83f3c179d7
|
||||
97
Assets/Scripts/Studio/UI/Panel_3DDy/ConnectionModal.cs
Normal file
97
Assets/Scripts/Studio/UI/Panel_3DDy/ConnectionModal.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using Studio.Conifg;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Studio
|
||||
{
|
||||
public class ConnectionModal : MonoBehaviour
|
||||
{
|
||||
private TextMeshProUGUI Text_Connection;
|
||||
|
||||
private Toggle autoIDCheck;
|
||||
private ConnectionItem connectionItem;
|
||||
|
||||
public Action<string> onTopicItem;
|
||||
public Action<bool> onIsAuto;
|
||||
|
||||
private bool isAuto;
|
||||
public void Init()
|
||||
{
|
||||
autoIDCheck = GetComponentInChildren<Toggle>();
|
||||
autoIDCheck.isOn = false;
|
||||
autoIDCheck.onValueChanged.AddListener(OnAutoCheck);
|
||||
connectionItem = GetComponentInChildren<ConnectionItem>();
|
||||
connectionItem.Init();
|
||||
connectionItem.onValueChange = SelectTopic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 토픽 데이터 변경했을때
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
private void SelectTopic(string key)
|
||||
{
|
||||
ActiveToggle(key);
|
||||
onTopicItem?.Invoke(key);
|
||||
}
|
||||
|
||||
private void ActiveToggle(string key =null)
|
||||
{
|
||||
if (isAuto == false)
|
||||
{
|
||||
autoIDCheck.gameObject.SetActive(isAuto);
|
||||
return;
|
||||
}
|
||||
|
||||
var isAutoID = string.IsNullOrEmpty(key) ? false : true;
|
||||
autoIDCheck.gameObject.SetActive(isAutoID);
|
||||
}
|
||||
public void SetAutoId(bool isAuto)
|
||||
{
|
||||
this.isAuto = isAuto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Moadl창 켜졌을때
|
||||
/// </summary>
|
||||
/// <param name="isAuto"></param>
|
||||
public void Open()
|
||||
{
|
||||
SetItem();
|
||||
ActiveToggle();
|
||||
}
|
||||
|
||||
private void OnAutoCheck(bool isbool)
|
||||
{
|
||||
onIsAuto?.Invoke(isbool);
|
||||
}
|
||||
|
||||
public void ChangeItem(string key,bool isOn)
|
||||
{
|
||||
var index = connectionItem.GetValue(key);
|
||||
connectionItem.AddConnection.SetValueWithoutNotify(index);
|
||||
autoIDCheck.SetIsOnWithoutNotify(isOn);
|
||||
ActiveToggle();
|
||||
}
|
||||
|
||||
|
||||
public void SetItem()
|
||||
{
|
||||
var mqttsetting = ConfigConnected.MQTTSettings;
|
||||
var topics = new List<string>();
|
||||
topics.Add("");
|
||||
foreach (var setting in mqttsetting.mqttConnections)
|
||||
{
|
||||
foreach (var topic in setting.topics)
|
||||
topics.Add(topic.topic);
|
||||
}
|
||||
|
||||
connectionItem.SetItem(topics);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93a7f8a195f788649886e3a765382621
|
||||
Reference in New Issue
Block a user