Functions throwing NullReferenceException in build only

Hello everyone,

I am about at my wits end with an issue I have been having with my functions in a couple of scripts. Everything works completely fine in the editor, but as soon as my team goes to build, these functions throw a NullReferenceException in the console of the developer build. Both of these script’s functions are meant to be called as animation events, but every time the events are called a null reference error is thrown.

I have attempted to find solutions to this issue online, but none of them are ever close to the issue I’m having. I have seen suggestions to edit the script execution order, but this does nothing to solve the issue.

Could this be something to do with the settings on the animation? I’m really not sure where to go from here. Any help would be appreciated.

EDIT: If it helps, the version I am using is 2019.3.0a5.

Why do you have your team building a project using an old early alpha of Unity 2019.3? Of course you’re going to hit problems.

Try the latest 2019.3 beta, see if the issue is resolved. Head over to the 2019.3 pre-release forum and see if anyone else is complaining about the issue and if a bug has been filed. File a bug report if no one else has, as Unity will want to fix as many bugs as possible before they release 2019.3.

https://forum.unity.com/forums/2019-3-beta.337/

Apologies, I should have noted that I already tried this and I am getting the same issue. Upgrading did not seem to result in any changes for better or worse.

Are you seeing this issue in 2019.2.x?

Just downgraded and built, and I am still experiencing the same issue.

Debugging a null reference exception in a build is pretty much the same as in the editor, just less convenient: Step through in a debugger, and/or add debugging output. Narrow down which variable is null, and work backwards to figure out where it became null / where it should have gotten a non-null value but didn’t.

1 Like