You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
623 B

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[RequireComponent(typeof(Button))]
public class ButtonShowHide : MonoBehaviour {
public bool startShowGroup;
public GameObject[] showHideGroup;
private bool show;
void Start () {
// This automatically registers the event click on the button component
GetComponent<Button>().onClick.AddListener(() => { Click(); });
show = startShowGroup;
ShowHideUpdate();
}
public void Click()
{
show = !show;
ShowHideUpdate();
}
private void ShowHideUpdate()
{
foreach (GameObject go in showHideGroup)
{
go.SetActive(show);
}
}
}