120 lines
3.8 KiB
C#
120 lines
3.8 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using XED.Manage;
|
|
using XRLib.UI;
|
|
|
|
namespace XED.UI
|
|
{
|
|
public class Panel_AppLogicList : PanelBase
|
|
{
|
|
Canvas_Studio_Popup studioCanvas_popup;
|
|
|
|
private List<UI_LogicItem> itemList = new();
|
|
public GameObject logicItem;
|
|
public RectTransform itemRoot;
|
|
|
|
public UI_LogicItem selectItem;
|
|
public PanelBase curInspectorPanel;
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
logicItem = Resources.Load<GameObject>("Prefabs/UI/PRF_LogicItem");
|
|
studioCanvas_popup = EventConnector.instance.GetCanvas<Canvas_Studio_Popup>();
|
|
CreateItem();
|
|
}
|
|
|
|
private void CreateItem()
|
|
{
|
|
UI_LogicItem item = Instantiate(logicItem, itemRoot).GetComponent<UI_LogicItem>();
|
|
item.onClickAdd += OnClickAdd;
|
|
item.onClickEdit += OnClickEdit;
|
|
item.onClickRemove += OnClickRemove;
|
|
itemList.Add(item);
|
|
}
|
|
|
|
private void OnClickAdd(UI_LogicItem item)
|
|
{
|
|
selectItem = item;
|
|
studioCanvas_popup.panel_selectlogic.Open(true);
|
|
}
|
|
|
|
private void OnClickEdit(ELogic logic)
|
|
{
|
|
if (curInspectorPanel != null)
|
|
{
|
|
curInspectorPanel.gameObject.SetActive(false);
|
|
curInspectorPanel = null;
|
|
}
|
|
var size = studioCanvas_popup.panel_inspector.rectTransform.sizeDelta;
|
|
var parent = studioCanvas_popup.panel_inspector.transform;
|
|
switch (logic)
|
|
{
|
|
case ELogic.AppSetting:
|
|
curInspectorPanel = studioCanvas_popup.panel_appsetting;
|
|
break;
|
|
case ELogic.Authentication:
|
|
curInspectorPanel = studioCanvas_popup.panel_authentication;
|
|
break;
|
|
case ELogic.Language:
|
|
curInspectorPanel = studioCanvas_popup.panel_multilingualsettingmodal;
|
|
break;
|
|
case ELogic.Logging:
|
|
curInspectorPanel = studioCanvas_popup.panel_loggingmodal;
|
|
break;
|
|
case ELogic.APIConnection:
|
|
curInspectorPanel = studioCanvas_popup.panel_apiconnectmodal;
|
|
break;
|
|
case ELogic.MQTTConnection:
|
|
curInspectorPanel = studioCanvas_popup.panel_mqttconnectmodal;
|
|
break;
|
|
case ELogic.Create3DObject:
|
|
break;
|
|
case ELogic.CreateUI:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (curInspectorPanel != null)
|
|
{
|
|
SetModal(size, parent);
|
|
}
|
|
}
|
|
|
|
public void SetModal(Vector2 size, Transform parent)
|
|
{
|
|
curInspectorPanel.transform.SetParent(parent);
|
|
curInspectorPanel.transform.localPosition = Vector3.zero;
|
|
curInspectorPanel.rectTransform.sizeDelta = size;
|
|
curInspectorPanel.gameObject.SetActive(true);
|
|
}
|
|
private void OnClickRemove(UI_LogicItem item)
|
|
{
|
|
itemList.Remove(item);
|
|
Destroy(item.gameObject);
|
|
|
|
if (selectItem == item)
|
|
{
|
|
selectItem = null;
|
|
if (curInspectorPanel != null)
|
|
curInspectorPanel.gameObject.SetActive(false);
|
|
}
|
|
|
|
if (itemList.Count == 0)
|
|
CreateItem();
|
|
}
|
|
|
|
public void OnSelectLogic(ELogic logic)
|
|
{
|
|
selectItem.OnSelectLogic(logic);
|
|
CreateItem();
|
|
studioCanvas_popup.panel_selectlogic.Open(false);
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
SetActive(true);
|
|
}
|
|
}
|
|
}
|