40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Panel_MeasuringTool : ToolPopupBase
|
|
{
|
|
public Button currentTabButton;
|
|
|
|
public void Awake()
|
|
{
|
|
var buttonDictionary = transform.FindComponentDictionary<Button>();
|
|
|
|
var toolPopups = FindObjectsByType<ToolPopupBase>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
|
|
|
foreach (var tabButton in buttonDictionary.Values)
|
|
{
|
|
tabButton.onClick.AddListener(() => SetTabMenu(tabButton));
|
|
}
|
|
}
|
|
public void SetTabMenu(Button tabButton)
|
|
{
|
|
ChangedTab(tabButton);
|
|
}
|
|
private void ChangedTab(Button tabButton)
|
|
{
|
|
if (currentTabButton != null && currentTabButton != tabButton)
|
|
{
|
|
currentTabButton.image.color = Color.white;
|
|
|
|
var preSelected = currentTabButton.transform.GetChild(0);
|
|
preSelected.gameObject.SetActive(false);
|
|
}
|
|
currentTabButton = tabButton;
|
|
currentTabButton.image.color = Color.black;
|
|
|
|
var selected = currentTabButton.transform.GetChild(0);
|
|
selected.gameObject.SetActive(true);
|
|
}
|
|
}
|