I have a gameobject that subscribes to an event but when the event is fired the Method does not get executed. My question is does the gameobject needs to be active on gamestart to subscribe to events?
public StationData station;
private void Awake()
{
GameManager.OnGamePhaseChanged += SetUIElementActive;
}
private void OnDestroy()
{
GameManager.OnGamePhaseChanged -= SetUIElementActive;
}
private void SetUIElementActive(GamePhase newPhase)
{
Debug.Log(newPhase.id == station.id);
if (station.id == newPhase.id)
{
gameObject.SetActive(true);
}
}
private void Start()
{
gameObject.SetActive(false);
}