// -------------------------------------------------------------------------------------------------------------------- // // Part of: Pun Cockpit Demo // // developer@exitgames.com // -------------------------------------------------------------------------------------------------------------------- using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; namespace Photon.Pun.Demo.Cockpit { /// /// Boolean UI UI Toggle input. /// public class BoolInputField : MonoBehaviour { public Toggle PropertyValueInput; [System.Serializable] public class OnSubmitEvent : UnityEvent { } public OnSubmitEvent OnSubmit; bool registered; void OnEnable() { if (!registered) { registered = true; PropertyValueInput.onValueChanged.AddListener(OnValueChanged); } } void OnDisable() { registered = false; PropertyValueInput.onValueChanged.RemoveListener(OnValueChanged); } void OnValueChanged(bool value) { OnSubmit.Invoke(PropertyValueInput.isOn); } public void SetValue(bool value) { PropertyValueInput.isOn = value; } } }