多个按钮控制多个窗体

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);
    }
}

  

以上是关于多个按钮控制多个窗体的主要内容,如果未能解决你的问题,请参考以下文章

C#:在窗体中放了多个文本框,我想要在里面输入数字,但要规定它不能超出范围,若超出范围,那就要提示

如何在 FAB 按钮单击时将数据从多个片段发送到单个活动

QT多个窗体切换显示

使用 Clip 对象播放多个声音片段

片段存储和重用:使用TabView的多个子片段

javascript如何在窗体中控制弹出网页的数量?