UI null reference errors in script, but not in inspector.
I'm working on a NPC interaction system, but something strange has happened when moving between scenes. I have a set up scene that has the necessary game objects and logic for moving between scenes. The game manager loads the village scene and everything works fine, you can interact with NPC's and the world normally. However moving into the next scene, and then back and trying to talk to NPC's causes a null reference exception error. Though when I check the inspector it shows the "missing field" as assigned. I do not have any other instances of the script in the world when this error occurs.
Edit: After further debugging, when UI method is called values are null, the only difference between setup scene to village and dungeon to village is the unloading of the village scene, could that have something to do with the error?
Answer by Xrank · Dec 20, 2021 at 11:38 PM
Turns out I’d wasn’t a problem with the editor, the script wasn’t properly disconnecting from an event, and that was enough to throw the error.