Is it true that event
in Unity's Monobehavior
is single threaded? When I trigger an event, if one of the listener raises an exception, the catch block will be executed. I assume once class A
fires an event, the thread will go over each subscriber. When each subscriber finishes, does class A
continue in the same thread?
public class EventExample : MonoBehaviour
{
public delegate void ExampleEventHandler();
public static event ExampleEventHandler OneDayPassed;
public void Start NextTurn()
{
try {
if (OneDayPassed != null)
{
OneDayPassed();
}
}
catch(Exception e)
{
// will catch error here
}
}
}
public class EntityWatcher : MonoBehaviour
{
void Start()
{
EventExample.OneDayPassed += this.PrepareNextDay;
}
public void PrepareNextDay()
{
int test = int.parse("error");
}
}