Adding InstructionEvent to the controller

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.

Get Augmented Reality for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.