In course Sam uses OnValidate function in ScriptableObject to build lookup tables.
OnValidate is not called during build/game, so we need to call OnValidate in Awake - like Sam mentioned.
But in course we have Awake in conditional compilation directive UNITY_EDITOR… sooo won’t it make not compile during build?
In Awake() we are creating one empty node, when we create instance of the DialogueNode.
Accoring to docs (Unity - Scripting API: ScriptableObject.Awake()):
Can we then loose the UNITY_EDITOR directive in this case?
Or maybe this way?
private void Awake()
{
#if UNITY_EDITOR
if (nodes.Count == 0)
{
nodes.Add(new DialogueNode());
}
#endif
OnValidate();
}