namespace UIWidgets.Examples { using System; using UIWidgets; using UnityEngine; /// /// Test Tabs. /// public class TestTabs : MonoBehaviour { /// /// Tabs. /// [SerializeField] protected Tabs Tabs; /// /// Adds listeners. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required")] protected virtual void Start() { Tabs.OnTabSelect.AddListener(Test2); } /// /// Remove listeners. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required")] protected virtual void OnDestroy() { if (Tabs != null) { Tabs.OnTabSelect.RemoveListener(Test2); } } /// /// Log selected tab info. /// /// Index. public void Test2(int index) { Debug.Log(string.Format("Name: {0}", Tabs.SelectedTab.Name)); Debug.Log(string.Format("Index: {0}", index.ToString())); Debug.Log(string.Format("Index: {0}", Array.IndexOf(Tabs.TabObjects, Tabs.SelectedTab).ToString())); } } }