Stuck in "Failed to load window layout" loop

When working on a custom editor window in Unity 2020 I caused the editor to crash. Upon trying to re-open it I received a “Failed to load window layout” dialog with the option to load the default layout or to reset to factory. Neither of these solutions would fix the issue and my only recourse was to cancel opening the editor. Does anyone know how to get Unity back up and running?

155416-unitylayoutbusted.gif

Things I have tried:

  • Deleting the Library and other generated project files
  • Creating a new project (Results in the same error)
  • Uninstalling and re-installing Unity
  • Deleting AppData\Roaming\Unity\Editor-5.x\Preferences\Layouts\default\LastLayout.dwlt

Editor.log

Failed to load window layout: System.NullReferenceException: Object reference not set to an instance of an object
  at UnityEditor.ContainerWindow.GetWindowID () [0x00070] in <a820952c8bdb44eba9c4c39808ab1e8a>:0 
  at UnityEditor.ContainerWindow.get_windowID () [0x00010] in <a820952c8bdb44eba9c4c39808ab1e8a>:0 
  at UnityEditor.ContainerWindow.SaveGeometry () [0x00001] in <a820952c8bdb44eba9c4c39808ab1e8a>:0 
  at UnityEditor.ContainerWindow.Save () [0x0000d] in <a820952c8bdb44eba9c4c39808ab1e8a>:0 
  at UnityEditor.ContainerWindow.Close () [0x00001] in <a820952c8bdb44eba9c4c39808ab1e8a>:0 
  at UnityEditor.WindowLayout.LoadWindowLayout (System.String path, System.Boolean newProjectLayoutWasCreated, System.Boolean setLastLoadedLayoutName, System.Boolean keepMainWindow) [0x000b7] in <a820952c8bdb44eba9c4c39808ab1e8a>:0
1 Like

Managed to solve the issue with help from a colleague at Unity who pointed me to the public source code for this part of the editor.

I was on the right track. The issue was caused by the editor trying to reload my custom editor window but being unable to for whatever reason (probably broken tbh). Deleting LastLayout.dwlt in the Roaming folder should have resulted in the editor falling back to the default layout, however what I did not realize was that there is an equivalent CurrentLayout file in the Library for the project. Deleting both the LastLayout.dwlt and the Library/ before attempting to re-open the editor cleared up the issue.

While I am here I want to point out that all of the solutions that I previously tried are valid solutions for different occurrences of this error; They were provided and tested by other users and provided as valid answers in other questions. If my answer does not solve your problem, consider trying one of those.

@metinevren
Copying \Library\CurrentLayout-default.dwlt form any working project to problematic project works like a charm.

It did not work. I cannot open a newly created project!! So ther ecannot be custom windows!

problem fixed here : Failed to load window layout in Unity - YouTube

I found the location: Reddit

,For the people having trouble with the location of the file, i found the solution on:
Reddit

For anyone who still has this issue, I made a script which can fix this for you.

Instructions are written in the comments, but the “gist” of it is, you edit line 20 and add in the path to the root folder containing your Unity projects.

You can add multiple paths if you have projects in different locations, as my Github packages were in a different folder than my main game projects. You then run the script, passing in the name of the project that is having issues (name must match the folder name which the project is in). The script makes a backup of your current layout file, detects the project’s version number via the project settings files, then uses that to go to the default Unity install folder to look for the matching Unity version install and copies the default layout file from there into your project’s Library folder.

You can then open up your project and should no longer be stuck in the layout loop.

It was happening so often that it warranted a script being written. Now I just open my terminal, type “unityfixlayout -Project MyProject” and then hit enter and go on about my business.

Currently, it is set up for Windows using Powershell, but I could adjust it for Mac/Linux since PowerShell is cross-platform, if there is a want/need for that.

I copied LastLayout.dwlt to the project directory then closed the project and re-opened it and this solved it for me.

just try this : in unity editor: Help → Check For Updates → uncheck the Check For Update

@Ratherjolly i have the same version now . how did you fix the problem plz.

Thank you.
The layouts in the project directories were what I was missing. I’ve been following instructions from several official threads with no luck, all missing this one piece. I can’t swear that some of the registry edits, other files I deleted, the Unity reinstall, PC reboot, etc. etc. didn’t play some part, but the piece that clearly finally solved it was removing the layout files in my projects.

I was getting this error for all new projects using 2020.1.6f1 (on PC).

Should it help anyone I can confirm that just deleting the “LastLayout.dwlt” from my roaming folder, and the “\Library\CurrentLayout-default.dwlt” from the project folder resolved the issue.

Thanks for the fix guys, but not sure what actually changed to trigger it? Was it the new version?

Hi all,

After getting frustrated with having to fix this issue every time I started unity, I created a python script that automatically fixes the issue. Here is the download link if anyone is interested: Unity layout fixer.py - Google Drive

Just run the file with python3 installed (https://www.python.org) and the issue will be fixed.

If you need a tutorial on how to use the patcher, watch this video: Untiy failed to load layout fix - YouTube

YES this solution does it. It happens that I started to get 2 windows on launch. One being black and if I close it it closes the project one and for all. Then the loop began… Prior to that I started using some custom package (that recorder one)

Anyways, removing the last layout from both the AppData and the your project folder works.

Now back to Unity. Thank you thank you!

I will try this solution, but I use a Mac. Does anyone know where the files for deletion can be found on MacOS?

Thank you.

Thank you so much

I had this issue and fixed it permanently by deleting the unity folders in appdata Local, localLow and Roaming, I can now open new projects without having to copy any Layout folders.
Hope this helps…

The thing is every resolution here is only opening the project once, after closing and opening it is broken again

172613-capture.jpg

copy - paste CurrentLayout.dwt and CurrentLayout-default.dwlt files from some other project you have in the library folder

Thanks a lot for the solution. Nothing makes the day better, than seeing perfect solutions like this one. Cheers!