首页 > 代码库 > 多个按钮控制多个窗体
多个按钮控制多个窗体
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); }}
多个按钮控制多个窗体
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。