auth and rc purchase dummy
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TabGroup : MonoBehaviour
|
||||
{
|
||||
public Button[] buttons;
|
||||
public GameObject[] contents;
|
||||
public int selectedIndex = 0;
|
||||
|
||||
|
||||
void OnValidate(){
|
||||
if(buttons == null || buttons.Length == 0){
|
||||
buttons=GetComponentsInChildren<Button>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
SetSelectedIndex(selectedIndex);
|
||||
|
||||
for(int i=0; i < buttons.Length; i++)
|
||||
{
|
||||
int index = i;
|
||||
buttons[i].onClick.AddListener(() => SetSelectedIndex(index));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetSelectedIndex(int index)
|
||||
{
|
||||
if(index < 0 || index >= buttons.Length) return;
|
||||
|
||||
selectedIndex = index;
|
||||
for(int i = 0; i < buttons.Length; i++)
|
||||
{
|
||||
buttons[i].targetGraphic.color = i == index ? buttons[i].colors.normalColor : buttons[i].colors.disabledColor;
|
||||
try{
|
||||
contents[i].SetActive(i == index);
|
||||
}catch{
|
||||
Debug.LogError("Content not found for index: " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d961ea20492fa0f448fbedacd3495911
|
||||
Reference in New Issue
Block a user