NaN Local Position Y for all parented by Canvas

My “canvas” objects always have a local position of NaN after I close out and open Unity. I try going into Debug Mode, but I still can’t change the values.

9147406--1271269--upload_2023-7-14_12-2-0.png

It happened to ALL of the children under “canvas”. Could I have done something potentially wrong?

9147406--1271269--upload_2023-7-14_12-2-0.png

I’m having the same issue; when you close Unity 2022.3.4f1, the editor messes with the scene file and makes some parts NaN for canvas items. one way to work around it is to discard changes from GIT before launching. this is a “bug”, so please mark it as so instead of question so devs can fix this in next version

I’ve encountered this bug as well on Unity 2022.3.4f1. All Y values for children under the UI canvas are set to NaN

The first time you open the UI prefab, you get spammed with the “graphic rebuild while we are already inside a graphic rebuild loop.” error.

It seems that going into play mode twice fixes the issue, for some reason

I made the mistake of saving my UI prefab while it was bugged, which meant all the Y values were saved as NaN

Probably related to this array of bugs: Canvas broken after loading project on 2022.3.3f1

It’s about time Unity used their Hub to provide Public Service Announcements for things like this.

1 Like

Yeah, you’re right. It’s probably related to that bug. Thanks for posting the link

Thanks guys. :slight_smile:

I have been having the same problem and it’s very annoying to fix it, but I just discovered that if your canvas is a prefab, you can just revert all “changes”, so it goes back to exactly what it was before. Especially useful if the values are not 0.
Hope this helps

The main cause of NaNs and Infinity in hierarchy is animating something to scale = (0,0,0)

Don’t EVER set the scale to zero: it can trigger divide-by-zero errors in the Layout Components of the UI hierarchy.

The proper way to set scales:

NEVER set scale (or any part of scale) to zero or negative.

NEVER use Vector2 because that makes the third term (Z) zero.

ALWAYS use Vector3, and make sure that the .z is either 1.0f, or else your non-zero scale.

Similarly never set scale to Vector3.zero, especially in a UI, because this will cause layout divide-by-zeros and damage all your hierarchy with either NaN or Infinity.

1 Like