Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
Fix an issue where the in-scene context manager object can get destroyed or appear multiple times. Fixes #530
Testing status
This issue is difficult to reproduce. What was happening is that starting EXR in edit-mode would set hideflags on all ContextManagers to
DontSaveInEditor
, meaning that the one from your open scene, as well as the one that EXR just created got these hideflags. Closing the window would destroy the new context manager object, but not restore the hideflags on the one in your scene. Then, when you change scenes, your original context would not be destroyed, resulting in two of these objects existing while only one showed up in the hierearchy. If you entered play mode, you would get hideflags ofNone
set on all EditingContextManagers, causing the second object to appear in the hierarchy. It was possible to "build up" a number of context objects this way.In the reverse, what would happen is simply that, once you got your in-scene editing context manager's hideflags set to
DontSaveInEditor
, the object will disappear once you enter Play Mode. For some reason this also causes it to get ignored in builds, and will not execute its scripts in play mode. The object still exists but it doesn't do anything.I was able to figure this out by creating an editor window with the following code:
Technical risk
Medium -- I'm not sure there was a particularly good reason why we were setting hide flags on >1 EditingContextManager in the first place.
Comments to reviewers
So glad to have squashed this bug. It was a tricky one, so it there may be some edge cases I'm missing.
For some reason this view https://github.com/Unity-Technologies/SuperScience#hiddenhierarchy-find-hidden-scene-objects didn't show those hidden editing context manager objects. I had to specifically use
Resources.FindObjectsOfTypeAll<EditingContextManager>()
for it to show up.