多个按钮控制多个窗体
Posted CocomoNo1
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多个按钮控制多个窗体相关的知识,希望对你有一定的参考价值。
using UnityEngine; using System.Collections; using UnityEngine.UI; public class WinControl : MonoBehaviour { public GameObject WinBtn1; public GameObject WinBtn2; public GameObject WinBtn3; public GameObject WinBtn4; public GameObject Win1; public GameObject Win2; public GameObject Win3; public GameObject Win4; //private GameObject temewin; // Use this for initialization void Start () { WinBtn1.GetComponent<Button>().onClick.AddListener(delegate() { this.OnClick1(WinBtn1.GetComponent<Button>()); }); WinBtn2.GetComponent<Button>().onClick.AddListener(delegate() { this.OnClick1(WinBtn1.GetComponent<Button>()); }); WinBtn3.GetComponent<Button>().onClick.AddListener(delegate() { this.OnClick1(WinBtn1.GetComponent<Button>()); }); WinBtn4.GetComponent<Button>().onClick.AddListener(delegate() { this.OnClick1(WinBtn1.GetComponent<Button>()); }); } void OnClick1(Button btn) { Win1.SetActive(WinBtn1 == btn); Win2.SetActive(WinBtn2 == btn); Win3.SetActive(WinBtn3 == btn); Win4.SetActive(WinBtn4 == btn); } }
以上是关于多个按钮控制多个窗体的主要内容,如果未能解决你的问题,请参考以下文章