114 lines
3.2 KiB
C#
114 lines
3.2 KiB
C#
using CHN;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
using WI;
|
|
|
|
namespace CHN
|
|
{
|
|
public class Panel_Menu : PanelBase
|
|
{
|
|
Button Button_Control;
|
|
Button Button_Graphic;
|
|
Button Button_Protocol;
|
|
Button Button_ETC;
|
|
Button Button_Reset;
|
|
Button Button_Accept;
|
|
Button Button_Close;
|
|
|
|
public List<SettingPanel> settingPanels = new List<SettingPanel>();
|
|
SettingPanel currentTab;
|
|
Button currentTabButton;
|
|
|
|
public override void AfterStart()
|
|
{
|
|
settingPanels.AddRange(GetComponentsInChildren<SettingPanel>());
|
|
|
|
Button_Control.onClick.AddListener(OnClickButton_Control);
|
|
Button_Graphic.onClick.AddListener(OnClickButton_Graphic);
|
|
Button_Protocol.onClick.AddListener(OnClickButton_Protocol);
|
|
Button_ETC.onClick.AddListener(OnClickButton_ETC);
|
|
|
|
Button_Reset.onClick.AddListener(OnClickButton_Reset);
|
|
Button_Accept.onClick.AddListener(OnClickButton_Accept);
|
|
Button_Close.onClick.AddListener(OnClickButton_Close);
|
|
|
|
SetActive(false);
|
|
}
|
|
public void Open()
|
|
{
|
|
if (gameObject.activeSelf)
|
|
return;
|
|
|
|
ChangePanel<Panel_ControlSetting>();
|
|
ChangeButtonState(Button_Control);
|
|
SetActive(true);
|
|
}
|
|
|
|
void ChangePanel<T>() where T : SettingPanel
|
|
{
|
|
foreach (SettingPanel panel in settingPanels)
|
|
{
|
|
panel.Close();
|
|
if (panel.GetType() == typeof(T))
|
|
{
|
|
panel.Open();
|
|
currentTab = panel;
|
|
}
|
|
}
|
|
}
|
|
void ChangeButtonState(Button button)
|
|
{
|
|
if (currentTabButton != null)
|
|
{
|
|
var selectedImage = currentTabButton.transform.GetComponentInChildren<RawImage>(true);
|
|
selectedImage.gameObject.SetActive(false);
|
|
}
|
|
currentTabButton = button;
|
|
var currentImage = currentTabButton.transform.GetComponentInChildren<RawImage>(true);
|
|
currentImage.gameObject.SetActive(true);
|
|
}
|
|
|
|
void OnClickButton_Control()
|
|
{
|
|
ChangeButtonState(Button_Control);
|
|
ChangePanel<Panel_ControlSetting>();
|
|
}
|
|
void OnClickButton_Graphic()
|
|
{
|
|
ChangeButtonState(Button_Graphic);
|
|
ChangePanel<Panel_GraphicSetting>();
|
|
}
|
|
void OnClickButton_Protocol()
|
|
{
|
|
ChangeButtonState(Button_Protocol);
|
|
ChangePanel<Panel_ProtocolSetting>();
|
|
}
|
|
void OnClickButton_ETC()
|
|
{
|
|
ChangeButtonState(Button_ETC);
|
|
ChangePanel<Panel_ETCSetting>();
|
|
}
|
|
|
|
void OnClickButton_Reset()
|
|
{
|
|
currentTab.Reset();
|
|
}
|
|
void OnClickButton_Accept()
|
|
{
|
|
currentTab.Accept();
|
|
}
|
|
|
|
void OnClickButton_Close()
|
|
{
|
|
SetActive(false);
|
|
}
|
|
}
|
|
}
|