75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using Studio;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using XRLib.UI;
|
|
using static UnityEngine.Analytics.IAnalytic;
|
|
|
|
namespace Studio.UI
|
|
{
|
|
public enum ProtocolType
|
|
{
|
|
API,
|
|
MQTT,
|
|
}
|
|
|
|
public class UI_ProtocolLabel : UIBase
|
|
{
|
|
public ProtocolType protocolType;
|
|
|
|
public Panel_DataRepository panel_Repository;
|
|
|
|
Button ClickButton;
|
|
Button FoldButton;
|
|
TextMeshProUGUI buttonText;
|
|
|
|
UI_DataRepositoryButtonList dataList;
|
|
|
|
string buttonName;
|
|
bool isFold;
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
buttonText = ClickButton.GetComponentInChildren<TextMeshProUGUI>();
|
|
dataList = GetComponentInChildren<UI_DataRepositoryButtonList>();
|
|
|
|
ClickButton.onClick.AddListener(OnClickButton);
|
|
FoldButton.onClick.AddListener(OnClickFoldButton);
|
|
}
|
|
|
|
void OnClickButton()
|
|
{
|
|
if (protocolType == ProtocolType.API)
|
|
{
|
|
panel_Repository.ShowInformation_API();
|
|
}
|
|
else if(protocolType == ProtocolType.MQTT)
|
|
{
|
|
panel_Repository.ShowInformation_MQTT();
|
|
}
|
|
}
|
|
|
|
void OnClickFoldButton()
|
|
{
|
|
if (isFold)
|
|
{
|
|
dataList.FoldButtons(true);
|
|
FoldButton.GetComponent<RectTransform>().localRotation = Quaternion.Euler(0f, 0f, 0f);
|
|
isFold = false;
|
|
}
|
|
else
|
|
{
|
|
dataList.FoldButtons(false);
|
|
FoldButton.GetComponent<RectTransform>().localRotation = Quaternion.Euler(0f, 0f, 180f);
|
|
isFold = true;
|
|
}
|
|
panel_Repository.RebuildLayout();
|
|
}
|
|
|
|
public void SetButtonName(string name)
|
|
{
|
|
buttonText.text = name;
|
|
}
|
|
}
|
|
}
|