Eflatun.SceneReference
Eflatun.SceneReference copied to clipboard
Entity SubScene Support
Entity scenes work differently from regular scenes.
Opening this issue even though entities is still in preview (though not for long if I heard right). I don't know if they will be modifying this, so perhaps it is too early, but I'll describe the current state.
- If you load a scene from the build settings, which contains a SubScene, everything works as expected. The SubScene does not need to be in the list directly (in fact, I suspect it is best to make sure it isn't).
- If you load a SubScene programmatically (using the guid given by this repository's SceneReference for example), the SubScene must be referenced by a scene (can be any) in the build settings, or it will not be able to be loaded.
Personally I've created a scene that contains all my SubScenes and I've added it to the build settings scene list. This works fine.
This sound like a problem with Entities and not this package. The only thing I can think of would be to display a warning message in this case, and that would be costly in terms of editor performance to implement, so I am not sure.
Also, I am a bit confused by your setup regarding the SubScenes, as they are not intended to be loaded like regular scenes, but rather they should already exist in another scene via the SubScene component.
The entities package has its own scene loading functionality for SubScenes, SceneSystem.LoadSceneAsync
. Determinism is important for us, so we load the subscenes one by one using this method.
To be fair, I haven't tried to use that function with a regular scene, but regular scene loading comes with a significant performance overhead, so I decided to load the subscenes directly.
I completely understand your remark about editor performance, and I do not have a good solution in mind either right now. If I recall correctly, in entities 0.5 there were build configurations which could reference entity scenes to be included, but they stopped using those.
I see, I haven't been keeping track of the Entities API lately. I will implement a scan feature then, but make it toggleable.
On a second look at the current API, I decided to wait until things stabilize, as there seems no way of implementing a scan feature easily at the moment other than a full instructions scan via reflection.
When the entities package is out of preview and it is officially supported, feel free to ping me about this issue again and I will reevaluate the options.
The entities package is at 1.0.11
now and goes with the 2022.3 LTS.
To summarize, a scene is added into the build if it's either:
- in a SubScene monobehaviour in a scene that's added into the build, or
- somehow baked in a subscene via strong or weak reference as described here
In our project we currently added a pre-build step where we add all subscenes from a scriptable object to a generated scene.
@Selmar Thank you for notifying me. I am currently working on Addressable Scene Support in #47. After it is done, I will look into this again.
I saw your message, seems you deleted it?
It seems to me that the only missing piece you need is the elimination of false negatives (scene not in build inline warnings) for SubScenes that are referenced by a scene in build, but not added to build directly.
I think this is almost correct, but I see a problem: I don't know how we can identify a scene as a SubScene or a regular Scene. Maybe we need a different wrapper type (i.e. Eflatun.SubSceneReference
)?
I saw your message, seems you deleted it?
It seems to me that the only missing piece you need is the elimination of false negatives (scene not in build inline warnings) for SubScenes that are referenced by a scene in build, but not added to build directly.
I think this is almost correct, but I see a problem: I don't know how we can identify a scene as a SubScene or a regular Scene. Maybe we need a different wrapper type (i.e.
Eflatun.SubSceneReference
)?
Yes, I realized there are some other parts that need to be addressed as well, one of them being what you mentioned, so I deleted the message.