Skip to content

Allow user to expose nodes within an instantiated scene #8266

@yahkr

Description

@yahkr

Describe the project you are working on

A re-usable ui framework that would allow a user to quickly and efficiently create new ui that follows the same formats and styles of the project. The only way to use the current system is to enable "Editable Children" on an instantiated scene.

Describe the problem or limitation you are having in your project

"Editable Children" clutters the scene tree dock and while functional, when modifying the underlying scene (moving/renaming), the child placed on the instantiated version becomes 'corrupt' losing its parent. This prevents the user from creating one scene and reusing it many times while maintaining the abilty to modify the underlying scene. In my case specifically UI related, but can be applied to all areas.

Example of using "Editable Children"
pr1

Describe the feature / enhancement and how it helps to overcome the problem or limitation

By allowing the user to expose nodes inside of an instantiated scene you can add children to specific sections of the subscene. This allows the user to re-use scenes as a type of custom container node.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I propose nodes get an additional bit of data added to them "exposed_in_owner" and related functions

--- node.h ---
bool exposed_in_owner = false;
void set_exposed_in_owner(bool p_enabled);
bool is_exposed_in_owner() const;

My current thought is having exposed nodes be dependent on also having a unique name within the scene so it's more straightforward when saving a scene to figure out where they should go. Current implementation forces 'unique_name_in_owner' on, but wont force it off if you disable the exposure setting.

Would love to get some feedback/assistance with this. @dmchurch if you see this, would love to work together on a solution :)

Things left to do ( for my implementation ):

(For reference lets assume Scene A instantiates a copy of Scene B, in which Scene B has an exposed node E):

Proof of concept parts done:

godotengine/godot#84018

Visual example of what I have so far:

pr2

If this enhancement will not be used often, can it be worked around with a few lines of script?

Would be used throughout a project, but if forced to workaround it could possible be done, not in a few lines of code, but an example of a workaround could be similar to @raulsntos 's suggestion here: @8184. However this approach has a lot of manual work for the user.

Is there a reason why this should be core and not an add-on in the asset library?

I don't currently see a way around this without being able to modify the scene_tree_dock/pack_scene/node code. Giving the user the ability to reuse code like this would increase readability of the Scene hierarchy and remove unnecessary duplication across the project.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions