Hey folks,
So I’ve run into a bit of a problem.
I’d like to use delegates and event handling in my Unity project to make my workflow much cleaner - however whenever an event is handle and I want it to do something I receive the error "___ Can only be called from the main thread. "
Does anyone have any experience with this? Work around?
Class Network()
public event ActionHandler Action;
public delegate void ActionHandler(string[] action);
private void ProcessAction(string[] message)
{
Action(message);
}
Class ActionManager()
void Start()
{
Network.Instance.Action += new Network.ActionHandler(OnActionReceived);
}
public void Action(string[] action)
{
if action[0] == 1
{
OpenDoor()
}
}
void OpenDoor()
{
this.animation.CrossFade("open_glassdoor");
}