Skip to content

Conversation

@yahkr
Copy link
Contributor

@yahkr yahkr commented Oct 26, 2023

Updated 9/8/2025

Description

This pull request implements a feature that significantly enhances Godot's scene editing capabilities. It allows specific nodes within a scene to be exposed, making them visible and allowing their properties to be overridden when the scene is instantiated elsewhere. I believe it is an improved version of editable children.

  • By exposing only relevant nodes, the scene tree editor remains uncluttered, which is especially useful for creating reusable scenes (Custom containers, Generic windows).
  • This PR also adds the ability to expose nodes on import, for use when wanting to expose parts of a scene (such as the hand bone of a character for equipping).

Note

  • Node exposure only propagates up one level of instantiation
  • Nodes that are exposed can be re-exposed

Important

The use of unique names has been removed from this PR (#84018 (comment)) as there were too many issues with it, once #106837 is merged this PR should function like originally planned

Example 1

Lets say we have this window scene that we want to re-use everywhere we can exposed the title label and the content nodes:

image

With this PR we can modify the properties of the exposed nodes and append child nodes to them, this lets us create super flexible scenes and use them like so:

image

and this is the same scene with editable children enabled. Far messier and poorer UX

image

Updated Example 2

image
[gd_scene load_steps=2 format=3 uid="uid://bg7bu82kitjht"]

[ext_resource type="Texture2D" uid="uid://dvj2xcm5vrvy8" path="res://icon.svg" id="1_mdjal"]

[node name="scene_0" type="Node2D"]

[node name="Parent" type="Node2D" parent="."]

[node name="Exposed_0" type="Sprite2D" parent="Parent" index="0"]
texture = ExtResource("1_mdjal")

+ [exposed path="Parent/Exposed_0"]
image
[gd_scene load_steps=3 format=3 uid="uid://da3f5wvbqv0bv"]

[ext_resource type="PackedScene" uid="uid://bg7bu82kitjht" path="res://scene_0.tscn" id="1_mdjal"]

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_3sd7o"]
load_path = "res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"

[node name="scene_1" type="Node2D"]

[node name="scene_0_instance" parent="." instance=ExtResource("1_mdjal")]

[node name="Exposed_0" parent="scene_0_instance/Parent" index="0"]
self_modulate = Color(1, 0.666667, 0, 1)

[node name="Child_Of_Exposed" type="Sprite2D" parent="scene_0_instance/Parent/Exposed_0" index="0"]
position = Vector2(100, 30)
scale = Vector2(0.5, 0.5)
texture = SubResource("CompressedTexture2D_3sd7o")

+[exposed path="scene_0_instance/Parent/Exposed_0"]  // Re-exposure 
+[exposed path="scene_0_instance/Parent/Exposed_0/Child_Of_Exposed"] // Initial Exposure

Sample Project

TODO

  • Fix remaining issues
  • Continue to test

I think that this pr addresses the following proposals:

@AThousandShips AThousandShips added this to the 4.x milestone Oct 26, 2023
@fire fire changed the title first pass - proof of concept Expose nodes inside of an instantiated scene instead of "Editable Children" - proof of concept Oct 26, 2023
@jcostello
Copy link
Contributor

This will work with imported gltf scenes?

@yahkr
Copy link
Contributor Author

yahkr commented Oct 27, 2023

This will work with imported gltf scenes?

I havn't looked into that aspect, but would be a nice feature to add to this as well

EDIT 11/2/2024:

Yes!

@AThousandShips
Copy link
Member

Also please update your branch by rebasing instead of merging, important skill to get used to with contributing, see the pr workflow for details

@yahkr yahkr force-pushed the exposed_in_owner branch 2 times, most recently from aacbd8c to c85dded Compare October 28, 2023 17:34
@yahkr yahkr closed this Nov 23, 2023
@AThousandShips
Copy link
Member

You have reset your branch and this closes the PR, if you update your branch this can be reopened

@AThousandShips AThousandShips removed this from the 4.x milestone Nov 23, 2023
@yahkr
Copy link
Contributor Author

yahkr commented Nov 24, 2023

Sorry, still trying to get a grip on correct way of updating my repo from main while keeping my changes. I've pushed my new changes up. This includes a somewhat functional version of this pr.

@yahkr yahkr reopened this Nov 24, 2023
@AThousandShips AThousandShips added this to the 4.x milestone Nov 26, 2023
@yahkr yahkr force-pushed the exposed_in_owner branch 7 times, most recently from 3233eac to 5257a35 Compare December 3, 2023 19:19
@DeanLemans
Copy link

what are the current issues with this PR that is preventing this from being merged?

@yahkr
Copy link
Contributor Author

yahkr commented Sep 12, 2025

what are the current issues with this PR that is preventing this from being merged?

Barring other technical issues my PR (most certainly) has. It really boils down to:

  • Is the way I'm proposing to solve this problem the best way to go?
  • Is it the best solution for those issues I've linked to this?
  • What happens to Editable Children if we go this route? (Deprecate/Remove/Maintain)

It sounds like after 4.5 releases this may get more discussion from maintainers. I'm confident that this workflow issue will be resolved one way or another. It's something I've been wanting since I started using Godot, and I really appreciate the thoughtful feedback and support from everyone following this PR.

image

@100gold
Copy link
Contributor

100gold commented Oct 25, 2025

There is a possible issue with "has_meta + set_meta" code. In some places code assume there can be 'false' value in meta. For example, here:

p_node->set_meta(META_EXPOSED_IN_OWNER, bool(node_settings["import/exposed"]));

Also, there is a lot of code like this:

bool exposed_node = p_node->has_meta(META_EXPOSED_IN_OWNER);

That code assume there is no option to have a 'false' value in meta. As far as I understand.

@yahkr
Copy link
Contributor Author

yahkr commented Oct 26, 2025

  • Updated to 0fdb93c
  • Removed void TreeItem::set_exposed(bool p_exposed) in favor of set_meta
  • Removed use of auto
  • Adjusted meta checks so it won't assign/read a false value (thanks @100gold)

Happy birthday to the PR 🎂2 Years🎉

@nubels
Copy link
Contributor

nubels commented Oct 27, 2025

The use of unique names has been removed from this PR (#84018 (comment)) as there were too many issues with it, once #106837 is merged this PR should function like originally planned

Just curious: #106837 has been merged, what about the use of unique names?

@yahkr
Copy link
Contributor Author

yahkr commented Oct 27, 2025

The use of unique names has been removed from this PR (#84018 (comment)) as there were too many issues with it, once #106837 is merged this PR should function like originally planned

Just curious: #106837 has been merged, what about the use of unique names?

I was using unique names when I first started this to mimic what that PR accomplishes. Thankfully we shouldn't have to change anything in this PR to gain the benefit from that one.

Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, haven't tested the functionality

@100gold
Copy link
Contributor

100gold commented Nov 17, 2025

I'm still facing error possible related to 'has_meta' issue. In editor, in scene that contains scene that contains exposed nodes there are error messages like this:

  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").

When I change all has_meta to get_meta(..., false) errors are gone.

@yahkr
Copy link
Contributor Author

yahkr commented Nov 18, 2025

I'm still facing error possible related to 'has_meta' issue. In editor, in scene that contains scene that contains exposed nodes there are error messages like this:

  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").
  ERROR: Node not found: "" (relative to "/root/@EditorNode@20534/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@4758").

When I change all has_meta to get_meta(..., false) errors are gone.

If you're able, could you provide a zip of a MRP?

I'm not sure why swapping it from has_meta to get_meta would change anything, but maybe I'm just missing something

@100gold
Copy link
Contributor

100gold commented Nov 23, 2025

Maybe I'm wrong about has_meta\get_meta thing. I don't sure why that change helps me in my main project. But anyway here is mrp with error.
mrp.zip

100gold added a commit to 100gold/godot that referenced this pull request Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet