I am trying to use the event system in Unity (C # path), but I am having problems with its implementation.
Most examples show one class in which you define a handler; then you write in the same class, a function that matches the signature of the handler, and you write events as static
public class EventExample : MonoBehaviour
{
public delegate void ExampleEventHandler();
public static event ExampleEventHandler OneDayPassed;
public static void NextTurn()
{
if (OneDayPassed != null)
OneDayPassed();
}
}
Then in another class, you subscribe to events, creating a function that actually does something
public class EntityWatcher: MonoBehaviour
{
void Start()
{
EventExample.OneDayPassed += this.PrepareNextDay;
}
public void PrepareNextDay()
{
}
}
, , , GameObject . , GO, 8 6, ; , script, Game Object, ?
, , 8 6 , , "", , .
, script , , , .
user393267