-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Redundant [default-CSGModel] is created on domain reload in wrong scene when using additive scene loading #386
Comments
On a more speculative note, line 145 of the same file says
Arguably, this feature can be counter-productive since it allows for brushes outside of a model to show in the editor which will then be stripped from a build, which seems likely to hide errors from users in a way that's difficult to identify. |
I just noticed that some default models were saved in my scene again, which may be a separate issue of its own. Not sure where to start searching for the cause of that one. |
Okay I think I've gotten closer to figuring this one out but I don't have time to thoroughly confirm right now.
According to the docs, objects marked There's also this post about some Unity hideflags weirdness but I have not explored that angle. https://forum.unity.com/threads/hideflags-hideflags-dontsave-being-saved-to-prefab.675523/ Going to just set everything to dontsave and hope nothing breaks for now. |
On a domain reload, RCSG reinitializes and creates an extra hidden
[default-CSGModel]
gameobject even when one is in the scene. It creates the object in the active scene rather than the scene with the model.The immediate cause is in
InternalCSGModelManager.DefaultModel.cs
at line 111 wheresceneState.DefaultModelObject
is set to a new gameobject. There appears to be no way in Unity to instantiate a gameobject in a particular scene unless creating a prefab for some reason.Adding
SceneManager.MoveGameObjectToScene(sceneState.DefaultModelObject, currentScene);
to the following line appears to move the gameobject successfully, but at the end of the domain reload it shows up in the hierarchy in the wrong place. I can't tell if it's being moved by some RCSG methods later in initialization, or some arcane Unity nonsense.On the next domain reload / initialization, the default model is searched for with
SceneQueryUtility.GetUniqueHiddenGameObjectInSceneWithName
, but that correctly searches the added scene and therefore doesn't find it, so it creates another one. If the scene is opened alone, or is set active during a reload, the hidden models are removed by that method.It appears that objects marked
DontSave
hang around through scene changes (additive or not) in the editor hierarchy if something has a reference to them.That may be part of the issue, but I have not 100% confirmed this.From the docs: "The object will not be saved to the Scene. It will not be destroyed when a new Scene is loaded. You must manually clear the object from memory using DestroyImmediate to avoid memory leaks."
A constant issue with rcsg in my experience is giant git diffs or git diffs for scenes with no changes, even when not saving meshes in scene files. Often the problem appears to be objects just shuffling their order in the hierarchy. Since Unity instantiates things in weird places in the hierarchy sometimes, this may be (one of) the causes of that issue as well.
The text was updated successfully, but these errors were encountered: