-
-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Describe the project you are working on
-
This is a hopeful continuation/discussion of Allow Scenes to specify where children of instantiations get placed in hierarchy (Shadow DOM) #8184
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"

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:
- add "Expose node in instantiated scene tool" to scene tree dock context menu
- add 'exposed_in_owner' to node data and save in scene file
- force unique_name_in_owner on, but don't force it off, when toggling exposed state
- add icon for exposed node (currently using svg from @dmchurch from Allow Scenes to specify where children of instantiations get placed in hierarchy (Shadow DOM) #8184)
- expose node E in scene A regardless of "Editable Children" status
- Save the node that is placed as a child of E within Scene A
Visual example of what I have so far:
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.
