Unsubscribe from event

Shouldn’t the UnitSelectedVisual script unsubscribe from the OnSelectedUnitChanged event?

private void OnDisable()
{
UnitActionSystem.Instance.OnSelectedUnitChanged -= UnitActionSystem_OnSelectedUnitChanged;
}

Sure you can handle unsubscribing either OnDisable or OnDestroy
However when you change scenes, like for example going into a Game Over or Game Win scene, when doing that all the objects are destroyed so there won’t be issues with events, as long as all objects are destroyed at the same time.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms