Properties panel now allows nested lists with foldouts, item selection and click callbacks Properties Panel UI has a new look Refactored lambdas in control module code into methods for readability
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class TabGroup : MonoBehaviour
|
|
{
|
|
public event Action<TabButton> OnTabChange;
|
|
private TabButton[] _tabButtons;
|
|
private TabButton _currentButton;
|
|
|
|
private void Start()
|
|
{
|
|
_tabButtons = GetComponentsInChildren<TabButton>();
|
|
foreach (var thisButton in _tabButtons)
|
|
{
|
|
thisButton.OnClick += () =>
|
|
{
|
|
if (_currentButton != null)
|
|
{
|
|
_currentButton.CurrentState = FlatButtonState.Unselected;
|
|
_currentButton.Tab.gameObject.SetActive(false);
|
|
}
|
|
|
|
_currentButton = thisButton;
|
|
_currentButton.CurrentState = FlatButtonState.Selected;
|
|
_currentButton.Tab.gameObject.SetActive(true);
|
|
OnTabChange?.Invoke(_currentButton);
|
|
};
|
|
thisButton.Tab.gameObject.SetActive(false);
|
|
}
|
|
|
|
_tabButtons.First().OnPointerClick(null);
|
|
}
|
|
}
|