Toggle开关

来源:互联网 发布:js获取浏览器的宽度 编辑:程序博客网 时间:2024/04/27 14:35
using UnityEngine;
using System.Collections;
using UnityEngine.UI;


public class MyToggle : MonoBehaviour
{


    public GameObject isOnGameObject;
    public GameObject isOffGameObject;


    private Toggle toggle;


// Use this for initialization
void Start ()
{
   toggle = GetComponent<Toggle>();
        OnValueChange(toggle.isOn);   
}

// Update is called once per frame
void Update () {

}


    public void OnValueChange(bool isOn)
    {
        isOnGameObject.SetActive(isOn);
        isOffGameObject.SetActive(!isOn);
    }
}
0 0
原创粉丝点击