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.