Skip to content

Add ClassType wrapper and Editor SceneTemplates

Will Nations requested to merge github/fork/willnationsdev/scene-templates into master

Closes #21187, #21203 (closed), and #22181.

This PR adds a "SceneTemplates" tab to the ProjectSettings window. This allows you to assign specific names to scenes, allowing them to then show up in the CreateDialog.

Because the logic of tracking inheritance hierarchies between engine classes, script classes, and scene templates was becoming quite complicated, I wrapped all of the associated logic into a ClassType class in the new class_type module. This will also enable us in the future to add class-name features to other parts of the engine (for example, exposing a class name string that must inherit from a particular class and provides enumerated options in the Inspector).

Adding scenes to the Scene dock in this manner executes more or less the same logic as using the chain-link icon.

You can also prefill a new entry in the SceneTemplates tab by using context menus in the Scene dock (for nodes that represent a scene) and in the FileSystem dock (for scene files).

These "SceneTemplates" are only accessible from the editor at editor-time. That is, these are NOT runtime-accessible typenames like script classes are.

(Note that in the below examples, "MySprite" is a scene with a Node2D root and a child Sprite)

SceneTemplates tab: scene_template_settings

CreateDialog entry: scn_temp_search

Adding a root "scene" node, i.e. inheriting a scene: scn_temp_inherited_scene

Adding a child "scene" node, i.e. instancing a scene: scn_temp_instanced_scene

Context menu in Scene dock: context_menu_scene

Context menu in FileSystem dock: context_menu_filesystem

Prefilled value: settings_populated

Let me know what you guys think.

Merge request reports