carlAlex
2/8/2017 - 12:59 PM

Custom events in unity

Custom events in unity

public delegate void nameOfDelegate(string text);
public static event nameOfDelegate OnStringEvent;


To raise:
OnStringEvent("ABC");

NameOfClassWithEvent.OnStringEvent += SomeMethod;

The method:
void SomeMethod(string text)
{
  //Do something
}