Skip to content

Commit

Permalink
Merge pull request #7 from CandyCoded/hotfix/remove-listener-on-disable
Browse files Browse the repository at this point in the history
[hotfix] Removed event listener on gameobject disable.
  • Loading branch information
neogeek authored Jul 12, 2020
2 parents 1a22c2f + 633eb23 commit fbfc01c
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 @@ -188,6 +181,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 fbfc01c

Please sign in to comment.