Edit Unity scene from outside or another way to repair a broken scene file

Yesterday I was trying to copy a lot of gameobjects from one scene to another, which led to many crashes at first, so I tried to copy smaller portions each time. When copying 2 parent objects and their childs at first it seemed to work, I saved, but then Unity crashed again. Now upon opening the project Unity crashes everytime. I surely know it’s caused by the scene, because renaming the scene and having Unity opening without the scene works, but trying to open the scene then crashes Unity again. I saw the scene file format is in plain text, I tried to delete the parts, that I thought corresponded to the newly copied over objects, but it didn’t work. Is there anyway to save my scene, like a program to edit it from outside? Thanks for your replies.

  • Create backups.
  • Use source control.

There is no way to restore your scene without knowing precisely what’s wrong with it.

If you manually edited it and did not keep a backup, it’s likely broken for good.

Thanks for the reply.

I did make a backup before editing it.

Sadly my attempts to restore the scene so far didn’t work. Bummer that there apparently is no way/tool to repair a scene.

You could mention the error message you get, or post the editor.log after a crash. Also editor version would be good to know. Slight chance the scene is okay but something else triggers the crash working with the scene’s contents.

And does the original scene or the one you copied into crash the editor?

Right now I don’t get any error message, but once I got one about being out of memory, I did notice my RAM usage goes to 100% when trying to open the project. I pasted the editor.log below. Editor version is 2022.3.8f1. The scene that I copied into crashes, which is my main scene.

Interesting. Crash seems to be related to D3D12 or rendering in general.

Try updating to 2022.3.29f1 first since you’re missing out on 20 patch updates.
And make sure you’re using the latest Nvidia driver, ideally switch to the Studio driver (not: game ready) as they’re said to be “for creative work” whatever that means (I assume it doesn’t do any game-optimization trickery).

If this still crashes, change the rendering path to D3D11 since 12 still happens to have a number of issues. It’s also really only useful in HDRP projects. (but I see you’re using HDRP but do try switching anyway if only to confirm that the crash is due to D3D12)

Running out of memory: how many game objects are in this scene? How big is the .unity file on disk? Perhaps you’re simply working with an excess amount of game objects in the scene, or with very deep hierarchies (eg dozens of parents). If you have more than 10,000 game objects or very deep hierarchies excess memory usage, slow editor performance, and lastly crashes are not uncommon.

1 Like

Thank you so much, it’s actually working now!

After updating my graphics driver I immediately did the switch from DX12 to DX11, since downloading a new Unity version takes a while for me. To my suprise, the scene now opens without crashing! I will setup Version Control now just to be safe for the future. :slight_smile:

1 Like

Excellent! Make sure you set it up properly. Here’s my handy cut-and-paste cheat sheet to get you going:

PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

I’m sorry you’ve had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

As far as configuring Unity to play nice with git, keep this in mind:

https://discussions.unity.com/t/736093/3

I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

Here is how I use git in one of my games, Jetpack Kurt:

https://discussions.unity.com/t/807568/3

Using fine-grained source control as you work to refine your engineering:

https://discussions.unity.com/t/826718/2

Share/Sharing source code between projects:

https://discussions.unity.com/t/719810/2

Setting up an appropriate .gitignore file for Unity3D:

https://discussions.unity.com/t/834885/5

Generally the ONLY folders you should ever source control are:

Assets/
ProjectSettings/
Packages/

NEVER source control Library/ or Temp/ or Logs/
NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

Setting git up with Unity (includes above .gitignore concepts):

It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It’s simply ridiculous not to back up.

If you plan on joining the software industry, you will be required and expected to know how to use source control.

Source control does require learning, but there are TONS of tutorials and courses and online reference.

You should strive to use source control as confidently as you use your file/folder system.

“Use source control or you will be really sad sooner or later.” - StarManta on the Unity3D forum boards