EventManager class:
public class EventManager : MonoBehaviour
{
public event EventHandler DialogEvent;
public static void ProcessEvent(IEvent eventObject)
{
EventManager eventMgr = ManagerRepo.Instance.EventMgr;
switch (eventObject.Type)
{
case EventType.Unknown:
break;
case EventType.Dialog:
eventMgr.DialogEvent(eventObject, EventArgs.Empty);
break;
default:
break;
}
}
}
And the handling method in another class:
private void HandleDialogEvent(object sender, EventArgs e)
{
NpcResponse response = sender as NpcResponse;
Debug.Log("Event received for keyword: " + response.Keyword);
}
The cast within the HandleDialogEvent method is not working and the variable response ends up being null.
Please check the attached screenshot for more details.
