Skip to content

Commit

Permalink
Removed event listener on gameobject disable.
Browse files Browse the repository at this point in the history
  • Loading branch information
neogeek committed Jul 12, 2020
1 parent 12fc625 commit 633eb23
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions Scripts/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ private void Awake()

_parentForm = gameObject.GetComponentsInParent<Form>().FirstOrDefault(form => !form.Equals(this));

if (_submitButton)
{

_submitButton.onClick.AddListener(HandleReturnPress);

}

}

private void Update()
Expand Down Expand Up @@ -183,6 +176,30 @@ public void LoadFormValues<T>(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<Dictionary<string, object>>
{
Expand Down

0 comments on commit 633eb23

Please sign in to comment.