I pop in and out of play mode a lot, and every time I either enter or exit play mode, the Hierarchy view collapses. This gets pretty tedious if I’m working on a specific object nested within the hierarchy.
Is there any way to prevent this behavior from happening? I’d prefer the hierarchy view’s state not change when toggling Play mode.
It looks like this doesn’t happen if I start a new project, leading me to believe there’s something specific in my project that’s causing this. Does anyone have any idea what type of code could be running to cause the root node in the Hierarchy view to collapse on Play mode change?
I am having the same problem and I think I found the reason. I am using a PreloadScene and whenever I hit play, Scene changes to PreloadScene and then the Preload scene redirects me to the Original scene I am working on. Because of these two redirects, Original scene forgets about the hierarchy tree state. Now I am searching for a way to eliminate preload scene altogether or restoring tree state after redirect. If I find a way I will let you know. Hope this helps. Have a nice day
BTW as a workaround until I find a definitive solution I am using this one-liner to select the game-object that I am working on in the hierarchy window.
I’m assuming it’s some combination of packages and 3rd party code, which will be a bit annoying/time-consuming to tease apart and isolate. I’m pretty sure this doesn’t happen on a brand new project. I’ll just need to set aside an hour to fuss with things to see what combination of code causes this to happen.
Well, I spent the expected hour trying to triangulate what’s causing the problem. Ultimately, I found the specific cause, but I don’t yet understand the reason.
My approach was to start deleting stuff from my project until the “collapse on play mode” behavior stopped happening. What I found is that it came down to a single Scene file in my project. If this Scene exists in my project, the bad collapse-on-play happens every time. If I remove the scene from the project, this behavior stops happening. Note that the presence of this scene in my project causes this behavior to happen in every other scene. So, it’s not like this one scene collapses. Just having this one scene in the project causes this to happen in every scene.
I deleted everything from the scene, and the problem persists. Interestingly, I also created a copy of the scene and deleted the original, and now the collapse-on-play behavior no longer happens.
So, my only conclusion is that there’s something just wrong with this scene, which isn’t related to its content. In my case, I can simply create a copy of this scene, delete the original, and now the problem no longer occurs. However, dropping this scene into a new project does not cause the problem to occur (even if I import identical package). However, if I duplicate the entire project, the problem does occur. But I can’t reproduce this in a small project. If I delete literally everything else in the project except for this scene, the problem no longer occurs. So, I’m left assuming there’s some subtle interaction between this scene and something else in my project which causes this behavior to occur.
Anyway, maybe if others are experiencing this issue they can try deleting individual scenes to see if it’s something related to scenes. (Obviously make a backup first before butchering your project.) Or maybe it could be any possible file in the project, and in my case it was just a scene. For now, I guess I’m all set, but I’m sorry I can’t contribute a reliable reproduction case to help isolate the issue.
More details on this. The behavior in my last post turned out to be just a side-effect. I claimed that it seemed to be caused by a certain scene, and I now believe that’s completely wrong. I now believe this is actually caused by the “Addressables” package.
I’m curious if any of the others who are running into this issue are also using Addressables in their project?
Anyway, if I completely remove the Addressables from my project, this no longer occurs. The reason I thought it was related to a specific scene is actually due to an Addressables bug ( Deleted scene results in Null Reference when building player content ). What was happening is, I deleted the scene I thought was causing the problem. Then when entering play mode, addressables would throw an exception due to the bug described in that link, which I believe prevented Addressables from running the rest of the code it would normally run when starting up a scene. I believe that somewhere in that “rest of the code” the Addressables package is causing the hierarchy to be collapsed.
Anyway, I guess now I’ll look through the Addressables code to see if I can pinpoint why. It would be nice to know if others are using Addressables, or whether there are just a lot of different reasons this collapse-on-play behavior can occur.
Now, either Build Player Content, or enter Play Mode, and the hierarchy view will collapse.
I have a simple test case that reproduces this, which I’m trying to submit as a bug, if the bug report system starts responding…
Anyway, it would be good to know if this is the same thing that’s causing issues for others, or if there are many ways the collapse-on-play is triggered.
This is happening to me as well, Unity 2020.1.7f1.
My project is literally a scene with a sprite with this script attached:
void Update()
{
if (Input.GetButtonDown(“Jump”))
{
SceneManager.LoadScene(0);
}
}
and it collapses the hierarchy when I hit space. This is a ton of extra time in the process to not be able to have an object remain selected in the inspector.
I have this issue whenever a load scene occurs. It’s getting extremely tedious. Do we have any feedback from the unity team about the issue? I’m using 2019.4.14f1
I’m having this problem as well. I’m reloading the scene using SceneManager for testing, but it collapses the whole hierarchy whenever it’s called. Annoying.