Closed PhoebeMitchell closed 2 years ago
Ran into that for the first time earlier, fixing my PRs, so I can vouch for the reproducibility of this.
The ideal solution in my mind would be to be able to set execution order inside C# (like a [ExecuteAfter(typeof(NarrativeScriptPlaylist))
attribute), that way it would pop in reviews if there's ever a change to it. That said, I don't think that sort of functionality exists inside Unity? (At least a quick Google search resulted in nothing of that sort; even though I vaguely remember something along those lines but I might be mixing things up with Unreal Engine.)
I kinda don't really see another way to resolve this. @PhoebeMitchell Do you already have a specific resolution in mind?
Maybe, as long as we wrap this in a test case that fails if the order is flipped and link to this ticket, using the "Script Execution Order" would be okay? Admittedly, it will be flakey again, if it's ever restored to the state it is in right now, but unless there's a way of forcing the order of execution inside C#, I don't really see a way around it.
I think you use [DefaultExecutionOrder(100)]
according to this
https://stackoverflow.com/questions/27928474/programmatically-define-execution-order-of-scripts/57141253
However I'm working on a DialogueController refactor which may help fix the order of execution.
Describe the bug
BGScenes are created in the Start method of BGScenesList. However DialogueController starts playing in its start method, and relies on BGScenes being loaded, or the &SCENE action will tell BGScenesList to load a BGScene that has not been created yet.
Steps To Reproduce
Open Inky-TestScene and run a narrative script where the first action is a &SCENE action e.g., MissingScenesDemo. You may or may not get the following error from BGScenesList.
Order of execution varies within Unity so it may work, it may not.
Expected behavior
The order of execution must be NarrativeScriptPlaylist's Awake method -> BGSceneList's Start method -> DialogueController's Start method.
Additional context
If you can do this without setting the order of script execution in Unity that would be good. Personally I feel setting the script execution order is a bit of a dirty fix and is very hard to debug if the order of execution is changed for whatever reason. I feel it'd be better to write the code in a way that indicates the order in which it is run.