I’m trying to solve a critical issue in my game that’s causing it to crash as soon as any RectTransform is changed. I have no idea why this is happening, all I did was refactor my Pause Menu UI to use RectTransforms instead of Transforms so I can use pixel space & make UI tweens work at any resolution.
Now, when I modify any RectTransform, my game crashes in a build. For example, the following line in Start() causes my game to crash instantly: confirmationPanel.localScale = Vector3.zero;
If I comment that line out the game doesn’t crash. But unfortunately for me, I guess, I need to be able to change RectTransforms.
I have no idea what happened or how to fix this but if anyone has any idea please let me know.
SOLVED! whew. When I switched the variable type for my panels, I fixed the type mismatches and updated my Pause Menu prefab. Somehow the prefab never saved so the types were still mismatched for my Main Menu scene and that was causing the crashes.
So, double-check your prefabs if you make a sweeping change like this
Yeah, that’s definitely a thing… if you change the type of a field that Unity is serializing for you but you leave the name exactly the same, BOOM!
The best approach I find is to rename it, at least trivially, and make sure all the serialization is removed.
Then name it back and drag all of your references back in.
Working with source control you will easily be able to see all the places that get changed… it will have a slightly different internal ID number, if I recall.