Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Context destroy bug #541

Merged
merged 2 commits into from
Mar 1, 2019
Merged

Fix Context destroy bug #541

merged 2 commits into from
Mar 1, 2019

Conversation

mtschoen-unity
Copy link
Collaborator

@mtschoen-unity mtschoen-unity commented Mar 1, 2019

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 of None 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:

var managers = Resources.FindObjectsOfTypeAll<EditingContextManager>();
foreach (var manager in managers)
{
    GUILayout.Label(manager.name + ", " + manager.gameObject.hideFlags);
}

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.

@mtschoen-unity mtschoen-unity requested a review from dunity March 1, 2019 02:21
# Conflicts:
#	Scripts/Core/Contexts/EditingContextManager.cs
@mtschoen-unity mtschoen-unity added this to the 0.2.1 milestone Mar 1, 2019
@mtschoen-unity mtschoen-unity merged commit 5a521b7 into development Mar 1, 2019
@mtschoen-unity mtschoen-unity deleted the fix-context-destroy branch March 1, 2019 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants