GameStudio does not persist the Name property of a scene asset
It seems the "Name" property of scenes is not getting carried over from the asset name to the actual object properties.
Repo in 2.0.2.1
- Create a new scene asset
- F2 and rename the scene
- Save project
- Open the .xkscene file, Name property is not being persisted.
- Query the Name property at runtime, all loaded scenes return a name of "Scene"
It's not a show stopper, but it makes it harder to walk the scene tree at runtime end makes Entity.Scene.Name ineffective as a way of identifying which scene an entity is in.
A.
Hello. Thanks for the report.
For historical reason each ComponentBase (including Entity and Scene) have a Name property. But only the Name for entities is serialized. For other components it is used for debugging purpose. We will consider renaming the property to DebugName and have a dedicated Name property for Entity.
In your case, you can get the asset url of a scene from the ContentManager:
// For example in a script attached to an entity
string url;
if (Content.TryGetAssetUrl(Entity.Scene, out url))
{
// ...
}
Thanks for that, it is certainly a viable approach.
In multi scene setups the scene is a fairly high level container so having names for them would be a nice to have, but obviously not critical. Does make it easier to wrap & write code like:
UnloadScene("IntroLevel");
Which is nice and clean in what it does.
There are obviously other ways to implement that, but it's some food for thought.
Thanks for the reply.