using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; [RequireComponent(typeof(Toggle))] public class RecordStop : MonoBehaviour { private Toggle toggle; public Text name; // Use this for initialization void Start () { toggle = GetComponent(); toggle.onValueChanged.AddListener(ValueChanged); } private void ValueChanged(bool isOn) { if (isOn) { name.text = "暂停记录"; } else { name.text = "正在记录"; } } // Update is called once per frame void Update () { } }