Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6.  
  7. public class ButtonPanel: MonoBehaviour {
  8.  
  9.     static List<Button> buttons = new List<Button>();
  10.  
  11.     void Awake() {
  12.  
  13.         buttons.AddRange(GetComponentsInChildren<Button>());
  14.  
  15.         foreach (var button in buttons) {
  16.             button.gameObject.SetActive(false);
  17.         }
  18.  
  19.     }
  20.  
  21.     public static void EnableButton(int index) {
  22.  
  23.         if (index < 0 || index >= buttons.Count) return;
  24.  
  25.         buttons[index].gameObject.SetActive(true);
  26.  
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement