diff --git a/Scripts/Form.cs b/Scripts/Form.cs index 6a6353e..8d8108b 100644 --- a/Scripts/Form.cs +++ b/Scripts/Form.cs @@ -32,13 +32,6 @@ private void Awake() _parentForm = gameObject.GetComponentsInParent
().FirstOrDefault(form => !form.Equals(this)); - if (_submitButton) - { - - _submitButton.onClick.AddListener(HandleReturnPress); - - } - } private void Update() @@ -183,6 +176,30 @@ public void LoadFormValues(T values) } + private void OnEnable() + { + + if (_submitButton) + { + + _submitButton.onClick.AddListener(HandleReturnPress); + + } + + } + + private void OnDisable() + { + + if (_submitButton) + { + + _submitButton.onClick.RemoveListener(HandleReturnPress); + + } + + } + [Serializable] public class SubmitEvent : UnityEvent> {