Scene Templates are brilliant yet painful to use

Hi!
I haven’t found any similar topic so I decided to create a new one. I really wanted to have something like scene templates for some time and when they were released I was super excited. Especially because our project is fairly complicated and modular, so SceneTemplates really can help.

BUT…

I suspect that the team that is working on never tested it in a real-life scenario. Why? I’ll try to explain from my point of view which is - working on a project with 2 scene templates and a lot of assets, I mean… a lot :slight_smile:

  1. Managing dependencies is really a pain in the ass. Without the ability to sort and search assets it is really tedious to scroll the enormous list and just checking on and off every single asset. I don’t think that our templates are really big, just a couple of prefabs assembled in a particular way.
  2. When the project grows… the scene templates also grow. But I totally don’t understand why. Maybe it is a bug or maybe it is a design of st. In my project, the scene templates changes by themselves. New assets, that are added to the project are being enabled in the dependencies automatically. They are not a part of the dependencies of any objects included in the scene of scene template or something. They just randomly pop up as dependencies to clone.
  3. I think that there is something wrong with the Terrain in the Scene Templates. When I try and include it to clone when creating a scene from scene template I think that terrain data isn’t properly referenced from the terrain component. Unity throws a warning because terrain data is different from terrain collider or something like this.

I really hope that someone from the scene templates team could join us and talk about it a bit more.

5 Likes

Sadly this is a recurring theme with unity. :-/

Here is an other example of an other feature that has been left unfinished even though fixit it would be easy. And that’s a random message from yesterday…

I hope you get a positive answer from the development team but my advice is to find a workaround as it might be a better solution.

1 Like

Hey @nehvaleem thanks for the feedback will discuss with the PM and dev team today - can you show some examples of the breadth of content you are templating please? feel free to email me on will@unity.com if its easier.

1 Like

Thanks for your feedback regarding scene templates.

1- About dependency management: we are plannign on adding a search field to help you manage dependency. I suppose it would be great to also be able to sort according to asset types.

2- Regarding dependencies: we compute all dependencies of your scene using AssetDatabase.GetDependencies. So if your “templated scene” is modified and is added new objects the dependency list will “grow”. We recompute the dependency list when the template is shown in UI or before template instantiation. If you feel “random objects” are added as dependency could you log a bug and attach your project (if possible) to the bug?

1 Like

Hi,

You can debug the dependencies of your scene by right clicking on it, and choosing “Select Dependencies”.

The list of dependencies should be the same as what is computed in the Scene Template EXCEPT for Scripts and Shaders which are not flagged as cloneable dependency.6744748--777523--select_dependencies.png 6744748--777526--select_dependencies_results.png

Thanks guys!
I’ll try to show you some examples from my use case in couple of days, but for now the most important parts for me are:

This is a huge step towards more UX for me. Having a really long list in regular inspector is another topic for me, but surely search & sorting are both great improvements

This confuses me a bit. I mean - sure, when “templated scene” changes (or prefab used in it change) the dependencies also changes, but what makes anyone certain that I want them to be cloned when creating a new scene? I feel like the scene template (and the cloning dependencies) are something that I specify. Maybe there should be some “policy” to set on a template that will define how to handle situations like this (default clone, default ignore)? Or maybe when scene dependencies changed between the moment the template was authored vs now there should be some “conflict” message that would make users to decide whether dependencies should be cloned or no?

Apart from above, I’ll try to show you guys some examples from my project but it will take me some time :slight_smile:

1 Like

Just to understand properly. Are you suggesting that:

1- When setup the dependency list of a template shouldn’t change (even if the scene itself has more or less dependencies)? In that case we could add a button to “update” dependencies.

2- Alternatively: by default we assume users might want to clone most dependencies. Maybe “new” dependencies should be “referenced” by default? (and not cloned?)

3- Alternatively, I don’t know if you were aware of this but in the Project Settings → Scene Template you can edit the “Default Template instantiation action” for each type of assets. By default a lot of types are set to clone. But you could remove the checkmark and make all of those “reference”. Then you could specify for each template what you actively want to clone.6745756--777655--scene_template_default_dependencies_action.png

I think that something between option 1 & 2 would be interesting. I think that after the user specifies dependencies they shouldn’t change without him knowiing. Instead I imagine that it would be awesome if there would be some sort of a message that can something like: “dependencies in scene has changed, decide whether to clone or reference them in scene template settings”

I know about the option that you have mentioned in 3 but it won’t help my case unfortunately.

The workflow you are suggesting is similar to Option #1 I suggested. Basically Dependencies are “frozen” on template creation but we can notify the user if some dependencies are outdated when the user clicks on the SceneTemplate (and on instantiation?).

yeah, exactly. This + better ui/ux for managing dependencies (filtering, sorting, etc) would make Scene Templates really better to work with :slight_smile:

Hi @sebastienp_unity how it’s going? Is there any progress, roadmap, upcoming features related to the scene templates available anywhere? I’m really excited about this feature being actively developed.

times goes by, questions left unanswered :frowning: And I was hoping that scene templates will become awesome eventually…

It is getting even worse to work with the scene templates actually. My dependencies list is so huge that it probably breaks the inspector and I am unable to toggle off cloning for some assets.

EDIT: It can be worked around by using debug view in the inspector.

@sebastienp_unity - is this package dead?

1 Like

This feature (Scene Templates) doesn’t work for our workflow either. I hoped I could use the Scene Templates as basis for new “level” in an existing game but there’s issues with the implementation and the UI. We’re using the latest Unity 2020.3 LTS branch.

Main issue is with the Scene Template Dependencies: Scene template system collects the dependencies too greedily.

In my template scene, I have a prefab link to a kind of Master object that contains basically all shared game logic, that should be in every level scene. Part of this Master object is a kind of repository system that contains references to pretty much every used asset in the game since the game is pretty dynamic in nature with lots of shared objects between scenes.

Scene Template system seems to assume I want to clone absolutely everything, even though I certainly don’t want it to clone stuff that’s in a linked prefab, unless I explicitly say so. For my template scene, I only want to clone 3 things (scriptable objects & terrain data). I can’t find them in the thousands of dependency objects shown even though my scene is basically “empty”. The object list isn’t even ordered in any sensible manner, but the list is really long and slows the editor down.

For my workflow, objects to clone should be opt-in. Currently Scene Template system seems to be designed for a “New project” thing rather than a “New scene in existing project” thing, and I need the latter.

As a workaround, I tried to use Scene Templates by removing my Master object (hoping it will reduce the amount of dependencies in the scene) and just having the terrain there which actually has something to clone, but even now the list of assets is almost 100 items long, full of all the textures and whatnot associated with the terrain splat material (all of which are shared between the levels). I don’t want changes to the material have any effect on my scene template (or vice versa) accidentally, so I prefer not to use Scene Templates for now.

I’m also not a fan of notifying about changes to irrelevant objects. Updating template scenes should be so rare, for me updating it’s dependencies should be an explicit thing to do, automatically changing files are a pain because of (mental) clutter in the version control system.

How I would fix the Scene Templates:

  1. Have a check box tree view for the dependency items based on asset path on disk
  2. Don’t assume references should be cloned unless explicitly marked as such (prevents automatic file changes when shared stuff is changed)

I’ll revert to my old way of doing this:

  1. Make a folder with the template scene stuff, including the assets that need to be cloned
  2. Have a custom level creation window that has a script that that copies your template scene folder and also renames all assets to match the new scene name
  3. Run code to fix references to the stuff that actually needed cloning, among other scene initialization like setting terrain size etc.

Cheers.

@sebastienp_unity - Any updates on Template Scenes? I like the concept, but the workflow is still lacking. I’ll add to the discussion that modifying the project’s Scene Template settings does not automatically check out the SceneTemplateSettings.json file from version control (I’m using Perforce Helix), so it results in an error:
UnauthorizedAccessException: Access to the path "D:\p4\IoD\ProjectSettings\SceneTemplateSettings.json" is denied.
Also, I recommend making Terrain, TerrainData, and TerrainCollider, and NavMeshData be cloned by default. Usually, different scenes represent different levels that have unique terrain geometry.

As of Unity 2020.3.30f1, even if you mark the TerrainData as cloned, it only clones the data for the TerrainCollider component and not for the Terrain component. Consequently, I had to write a Scene Template Pipeline script that copies the TerrainData from the TerrainCollider component to the Terrain component after template instantiation.

    public class SceneTemplatePipeline : ISceneTemplatePipeline
    {
        public void AfterTemplateInstantiation(SceneTemplateAsset sceneTemplateAsset, Scene scene, bool isAdditive, string sceneName)
        {
            if (!scene.IsValid())
            {
                Debug.LogError($"{sceneName} is invalid. Cannot run the template pipeline script.");
                return;
            }
            var rootObjects = scene.GetRootGameObjects();
            foreach (var rootObj in rootObjects)
            {
                Terrain terrain = rootObj.GetComponent<Terrain>();
                if (terrain == null) continue; // NOTE: this assumes all terrain objects are root objects
                // Copy TerrainData from the TerrainCollider component to the Terrain component.
                TerrainCollider terrainCollider = terrain.GetComponent<TerrainCollider>();
                if (terrainCollider == null) continue;
                if (terrainCollider.terrainData == null) continue;
                terrainCollider.terrainData.name = scene.name + "_Terrain"; // update the name to avoid confusion
                terrain.terrainData = terrainCollider.terrainData;
            }
        }

        public void BeforeTemplateInstantiation(SceneTemplateAsset sceneTemplateAsset, bool isAdditive, string sceneName)  { }

        public bool IsValidTemplateForInstantiation(SceneTemplateAsset sceneTemplateAsset)
        {
            return sceneTemplateAsset.isValid;
        }
    }

Remember to insert this script into your Scene Template asset.

I’ve struggled with this issue a lot, but iirc it is fixed in 2021.2. It is something :slight_smile:

Hi. Sorry for the late reply. Scene Template was put on maintenance a while ago. The issue you mentioned is fixed in 2022.2.

Can you log a bug for this? This is something that can potentially hit a lot of users.

This was fixed in 2021.2.

Since 21.2, you can now filter the list and sort the dependencies based on their name or type.

@Will-Goldstone there is some great feedback in this thread. It would be great to gather that information and take some time to review and act on it.

1 Like

This is good to hear. Let me add to the feedback pile :wink:

It came up earlier that in the Project Settings, you can change what types of assets are cloned by default. It would be great if this list started out unchecked by default. The default assumption should be “clone nothing,” rather than “clone everything.”

EDIT: Once that’s done, a good next step might be to crib off the Importer Preset system and introduce name-based clone conditions, e.g. “clone all Timelines by default whose names start with LevelIntro.”