October 2017
Intermediate to advanced
548 pages
13h 23m
English
The first step in refactoring our code to use events and listeners is to define a UnityEvent called InstructionEvent. Open InstructionsController.cs and add the following:
File: InstructionsController.cs
using UnityEngine.Events;
public class InstructionEvent : UnityEvent<InstructionStep> { }
public class InstructionsController : MonoBehaviour {
public InstructionEvent OnInstructionUpdate = new InstructionEvent();
...
As you can see, we also declare a public InstructionEvent named OnInstructionUpdate, which is what all our UIs will be listening to, so we can ensure they update correctly.
Read now
Unlock full access