Building to ios I get a bunch of null refs, looking into it it turns out variables filled with a getcomponent call return null until the next frame in a ios build.
for instance with:
public Transform someTransform;
someTransform = gameObject.transform;
someTransform, remains null until the next frame.
I jumped from unity 3 to 2017, so maybe I’ve missed something? Any ideas as to why this is and what has to be done to access the component right away like the behavior in the editor?
Ok turns out it wasn’t every getcomponent, only the getcomponents that use: FindWithTag.
Adding a yield just moved the problem to the next frame, which I didn’t notice at first.
Looking at the tag manager, I noticed there were 2 (removed) tags. And Unity notified me that they would be removed on the next start of the project. So I imagine that in the build the removed tags messed up the order, resulting in the null refs.
Restarting the project did nothing however, as the “removed” tags were still there. Adding a new tag, then restarting the project fixed that, and now the null refs are gone!