156 lines
5.0 KiB
C#
156 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static UnityEditor.Profiling.HierarchyFrameDataView;
|
|
|
|
namespace EnglewoodLAB
|
|
{
|
|
public class Panel_ToolBar : MonoBehaviour
|
|
{
|
|
public Button Button_Logo;
|
|
|
|
public Button Button_Layout;
|
|
public Button Button_Settings;
|
|
public Button Button_Monitoring;
|
|
public Button Button_Simulator;
|
|
public Button Button_EnvSettings;
|
|
public Button Button_Search;
|
|
|
|
public Button currentSituationButton;
|
|
|
|
public Action<string> onClickLayout;
|
|
public Action<string> onClickSettings;
|
|
public Action<string> onClickMonitoring;
|
|
public Action<string> onClickSimulator;
|
|
public Action<string> onClickEnvSettings;
|
|
|
|
public Action onClickScreenInitialization;
|
|
public Action onClickExit;
|
|
|
|
private bool isClickable;
|
|
|
|
private void Awake()
|
|
{
|
|
//var buttonDict = transform.GetChildComponentsByName<Button>();
|
|
//var toggleDict = transform.GetChildComponentsByName<Toggle>();
|
|
|
|
//Button_Logo = buttonDict.GetOrNull(nameof(Button_Logo));
|
|
|
|
//Button_Layout = buttonDict.GetOrNull(nameof(Button_Layout));
|
|
//Button_Settings = buttonDict.GetOrNull(nameof(Button_Settings));
|
|
//Button_Monitoring = buttonDict.GetOrNull(nameof(Button_Monitoring));
|
|
//Button_Simulator = buttonDict.GetOrNull(nameof(Button_Simulator));
|
|
//Button_EnvSettings = buttonDict.GetStringOrNull(nameof(Button_EnvSettings));
|
|
|
|
//Button_Search = buttonDict.GetOrNull(nameof(Button_Search));
|
|
|
|
Button_Logo.onClick.AddListener(OnClickResetButton);
|
|
|
|
Button_Layout.onClick.AddListener(OnClickLayout);
|
|
Button_Settings.onClick.AddListener(OnClickSettings);
|
|
Button_Monitoring.onClick.AddListener(OnClickMonitoring);
|
|
Button_Simulator.onClick.AddListener(OnClickSimulator);
|
|
Button_EnvSettings.onClick.AddListener(OnClickEnvSettings);
|
|
|
|
Button_Search.onClick.AddListener(OnClickResetButton);
|
|
}
|
|
private void Start()
|
|
{
|
|
}
|
|
public void SetClickable(bool isClickable)
|
|
{
|
|
this.isClickable = isClickable;
|
|
}
|
|
private void OnClickLayout()
|
|
{
|
|
if (isClickable)
|
|
return;
|
|
|
|
ChangedSituationButton(Button_Layout);
|
|
onClickLayout?.Invoke("Layout");
|
|
}
|
|
private void OnClickSettings()
|
|
{
|
|
if (isClickable)
|
|
return;
|
|
|
|
ChangedSituationButton(Button_Settings);
|
|
onClickSettings?.Invoke("Settings");
|
|
}
|
|
private void OnClickMonitoring()
|
|
{
|
|
if (isClickable)
|
|
return;
|
|
|
|
ChangedSituationButton(Button_Monitoring);
|
|
onClickMonitoring?.Invoke("Monitoring");
|
|
}
|
|
private void OnClickSimulator()
|
|
{
|
|
if (isClickable)
|
|
return;
|
|
|
|
ChangedSituationButton(Button_Simulator);
|
|
onClickSimulator?.Invoke("Simulator");
|
|
}
|
|
private void OnClickEnvSettings()
|
|
{
|
|
if (isClickable)
|
|
return;
|
|
|
|
ChangedSituationButton(Button_EnvSettings);
|
|
onClickEnvSettings?.Invoke("EnvSettings");
|
|
}
|
|
|
|
private void OnClickResetButton()
|
|
{
|
|
if (isClickable)
|
|
return;
|
|
onClickScreenInitialization?.Invoke();
|
|
}
|
|
|
|
private void OnClickExit()
|
|
{
|
|
if (isClickable)
|
|
return;
|
|
|
|
onClickExit?.Invoke();
|
|
}
|
|
|
|
private void ChangedSituationButton(Button button)
|
|
{
|
|
if (currentSituationButton != null)
|
|
{
|
|
ChangedSituationButtonTexts(currentSituationButton, false);
|
|
}
|
|
currentSituationButton = button;
|
|
ChangedSituationButtonTexts(currentSituationButton, true);
|
|
}
|
|
public void DeselectedSituationButton(string pName)
|
|
{
|
|
//var buttons = transform.GetChildComponentsByName<Button>();
|
|
//var button = buttons.FirstOrDefault(x => x.Key.Contains(pName)).Value;
|
|
|
|
//ChangedSituationButtonTexts(button, false);
|
|
}
|
|
private void ChangedSituationButtonTexts(Button button, bool selected)
|
|
{
|
|
var buttonTexts = button.transform.GetComponentsInChildren<TextMeshProUGUI>(true);
|
|
buttonTexts[0].gameObject.SetActive(selected);
|
|
buttonTexts[1].gameObject.SetActive(!selected);
|
|
}
|
|
private void ChangedSettingButtonColor(Button button)
|
|
{
|
|
var icon = button.transform.GetChild(0).GetComponent<Image>();
|
|
var text = button.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
|
var color = text.color == Color.white ? new Color(0.36f, 0.75f, 1) : Color.white;
|
|
|
|
text.color = color;
|
|
icon.color = color;
|
|
}
|
|
}
|
|
}
|