For some reason when I first open my project my UI looks like this. If I run it once then stop it, the UI goes back to normal. If I close Unity and reopen, it goes back to the weird view with the red X’s. Ideas?
Red X is usually just anchoring errors that have turned a RectTransform inside out.
Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:
Usually you need to choose a suitable ScaleMode and MatchMode in the Canvas Scaler and stick with it 100%. Generally if you change those settings you will often need to redo your UI entirely.
I also use this CanvasScalerOrientationDriver
utility to make sharing UI for Landscape / Portrait easier. Read what it does carefully.
This has just gotten worse. And now I’m getting this error over and over until I run and stop again. I don’t see anything that would be “inside out”. I don’t even know what ScaleMode or MatchMode are so I’m pretty sure I haven’t changed that. I’m not using portrait, this is only a desktop app.
Assertion failed on expression: 'IsFinite(distanceForSort)'
I found the Canvas Scaler on both the canvases in my scene. Both are set to “Contstant Pixel Size”.
Which version of Unity are you on? You can try updating to 2022.3.5f1. I know there were some UI-related fixes.
So there are two things happening.
- The canvas size is 0,0 when I launch Unity. In addition to running the project, I can also simply switch to the “Game” tab. Once this is done, the canvas size is correct.
- Some properties are reverting when I close and reopen Unity.
This seems to be a Unity bug. It is reproducible. Here is a video of the issue:
Thank you. Downloading now.
Updating to 2022.3.5f1 fixed the problem immediately.