All UI disappeared upon saving and exiting.

Hello, I am making a little passion project game and like usual, yesterday I saved my project and clicked the X at the top right to close. Today i open up my project and all my UI disappeared with the transformations of all of them having NaN in some of their position and anchors. Even after getting rid of said NaN’s the UI will not show up at all. I am getting error “Invalid AABB inAABB UnityEngine.StackTraceUtility:ExtractStackTrace ()”. The thing is that I can implement other new UI elements perfectly fine like creating a new text. I think it also worth mentioning I have a backup of my project from four days ago and I opened it up to discover it was also effected by the same problem. Any help is appreciated, I am kind of freaking out of thought of restarting all my UI work from scratch. If any additional information is needed I can totally do that.

1 Like

I had a similar error, I tried many things out that could fix the issue, here are some solutions wich perhaps work.

Solutions that might help depending on how the bug developed.

  1. Create Backup: Before proceeding with troubleshooting, create a backup of your project. This ensures you don’t lose your work if anything goes wrong.

  2. Clear Unity Cache: Sometimes clearing the Unity cache can help resolve such issues.

  • Close Unity.
  • Delete the contents of the “Library” folder in your project’s root directory. Note that this will recreate project files and may take some time.
  • Reopen the project in Unity.
  1. Check UI Elements: Open the scene containing the affected UI elements and inspect the Transform components.
  • Look for UI elements with NaN values in their transformation fields (Position, Rotation, Scale).

  • Manually reset these values to valid ones. For example:

  • Position: (0, 0, 0)

  • Rotation: (0, 0, 0)

  • Scale: (1, 1, 1)

  1. Verify Scene Settings: It’s possible that camera or other scene settings have been altered.
  • Check camera settings, especially Viewport Rect and Clipping Planes.
  • Ensure the camera is pointing to the UI layer.
  • Review Canvas settings, particularly Render Mode (e.g., Screen Space - Overlay).
  1. Reset UI Elements in Prefabs: If you’re using prefabs for your UI elements, it may help to inspect and reset them.
  • Open the prefabs in prefab mode.
  • Check and reset the transformation values of the UI elements.
  1. Debugging in Scripts: If you have scripts manipulating the UI elements, inspect them for errors.
  • Look for logic that could affect transformation values.
  • Add debugging logs to see when and why the values become NaN.

Solution that worked for me
Possible: PC Restart Fix:
Restarting your PC might resolve the issue due to several reasons:

  • Temporary Files and Cache: A restart might clear damaged or outdated temporary files and cache data used by Unity, which could cause errors.
  • System Resources: Restarting can help address memory leaks and excessive resource usage, common culprits for errors in applications, including Unity.
  • Unity Editor State: Restarting resets the Unity editor to a fresh state, potentially fixing issues caused by the previous state.
  • Background Processes: Ongoing background processes or other applications might interfere with Unity, and a restart can halt these to prevent conflicts.
  • GPU Drivers and Graphics Issues: Restarting can initialize graphics drivers anew, resolving graphics-related problems.

Conclusion:
Preventive Measures: To avoid similar issues in the future, consider these measures:

  • Regular backups
  • Project and Unity updates
  • Clearing cache and temporary files
  • Monitoring system resources
  • Updating GPU drivers

I hope that one of these solutions worked for you. I recommend to try the easy steps first (4-6), than the time consuming once like (2, 3). Try out a PC-restart, wich can often solve unity bugs.