Bogus Null Reference in Build only,Bogus Phony NULL REFERENCE in BUILD ONLY (works in editor)
Game works fine in editor, but the build has bugs. Thus development build compiled, launched and PlayerLog logged. Open file. Error is:
NullReferenceException: Object reference not set to an instance of an object at DamageZone.OnTriggerEnter (UnityEngine.Collider other) [0x00090] in E:\game projects\Dungeons Of Futanaria\Assets_script\DamageZone.cs:75
That's rather strange, because the any reference that could be the culprit is very clearly assigned. Which is why it works in the editor. And it is assigned assuming the same principles of logic and consistency that I applied to every other script and bit of code throughout my project, which is why they work and they can be assumed to keep working and not randomly give bogus null reference exceptions. Or so I thought?
I assign the variable in the start method (which is a method I've naively assumed to not be prone to random errors, my bad Unity) like so:
And as an additional precaution I added this to the method that is being claimed 'null reference my ass' in the log file:
Forgive the crude language, I have been renaming my scripts and variables during the process of trying to debug this and at some point patience kind of runs low.
Hello.
i really didnt read you post, but for your title, maybe this solve your problem.
Once i had a similar problem because the scripts, in the editor, where executing in different order than in build game. So one variables were null.
Be sure to assign an order of execution for your scripts:
https://docs.unity3d.com/$$anonymous$$anual/class-$$anonymous$$ono$$anonymous$$anager.html
Good Luck!
But that's incredibly retarded, why would Unity use script execution order 'A' for the editor, but a different order for the build? I cannot imagine the Unity developers being so incredibly moronic that this would be the case.
At the same time I suspect it does have something to do with that. I checked the link and yeah you can set the script execution order for literally everything manually but jesus christ where to even start?
I appreciate the effort though.
But that's incredibly retarded, why would Unity use script execution order 'A' for the editor, but a different order for the build? I cannot imagine the Unity developers being so incredibly moronic that this would be the case.
At the same time I suspect it does have something to do with that. I checked the link and yeah you can set the script execution order for literally everything manually but jesus christ where to even start?
I appreciate the effort though.