-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to expose nodes for direct access in instantiated scenes #84018
base: master
Are you sure you want to change the base?
Conversation
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 |
Also please update your branch by rebasing instead of merging, important skill to get used to with contributing, see the pr workflow for details |
aacbd8c
to
c85dded
Compare
3d44605
to
ac26465
Compare
ac26465
to
2144053
Compare
You have reset your branch and this closes the PR, if you update your branch this can be reopened |
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. |
3233eac
to
5257a35
Compare
5257a35
to
03e1647
Compare
Works perfectly so far! The only minor issue I've found is that it's possible to edit exposed nodes that are no longer there if you have previously selected it: Screencast.From.2024-10-30.17-11-43.webm |
4bce813
to
6703e8e
Compare
fixed! thanks! |
6703e8e
to
1b06199
Compare
Thanks for the report, I think I see whats happened and have pushed a hopeful fix. I wasn't correctly identifying when an exposed parent node did or did not exist anymore. The issue was when a node was added as a child of an exposed node, it creates a path like this: [node name="base" parent="." instance=ExtResource("1_mdjal")]
[node name="SecondParent" type="Node2D" parent="base/%Exposed" index="0"]
[node name="Child_Of_Child_Of_Exposed" type="Sprite2D" parent="base/%Exposed/SecondParent"]
texture = ExtResource("2_bbwan") I needed to traverse up the parent path to see if that exposed node is still exposed or not. Can you please try this again? If it doesn't work I would love a project that reproduces this issue for you. |
1b06199
to
74beaad
Compare
Issue appears to be fixed, cheers! The nodes stay together after restarting Godot, and the terminal output is clear |
I found another interesting bug: You need:
Now instantiate the second scene in the main scene and save. Close the main scene and reopen it. Save again, close and reopen it. You should see random AnimationPlayer nodes appear in the main scene as children of the instantiated scene. Screencast.From.2024-10-31.20-39-56.webmThis does not happen if I compile from the same commit without this PR. |
Very strange... diff between PR scene and normal scene Will continue to dig in :) EDIT: Figured it out, will work out the fix tomorrow. Thanks for testing!! |
I think putting the unique name features to the backlog for now would bet better. Looking at the Unique ID proposal, that doesn't seem to be close to done anytime soon and I think this feature/PR is too useful by itself to completely stall it. |
74beaad
to
7a50bdf
Compare
Thanks everyone for their help/feedback! I went ahead and removed the unique name aspect from this pr and updated the description 😥. Feel free to give it another go and let me know if you run into any more issues. |
7a50bdf
to
e111cd9
Compare
Exposing a node inside editable instance will make it also editable in the parent scene and appear as if every node was exposed in the parent scene. godot.windows.editor.dev.x86_64_d0sN6tGBaK.mp4 |
I don't think this should be allowed, since exposure should be controlled from the scene in which the node originates, so i will prevent that expose button from appearing when editable children is enabled and it isn't already exposed. Edit:
|
374379b
to
da3c90e
Compare
You can still expose editable child using the shortcut. |
@@ -33,6 +33,7 @@ | |||
|
|||
#include "editor/gui/scene_tree_editor.h" | |||
#include "editor/script_create_dialog.h" | |||
#include "editor_undo_redo_manager.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be included in cpp file.
_update_children_cache(); | ||
Node *const *cptr = data.children_cache.ptr(); | ||
int ccount = data.children_cache.size(); | ||
for (int i = 0; i < ccount; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't iterate on children cache, you can iterate on children directly with
for (KeyValue<StringName, Node *> &KV : data.children) {
bool exposed_in_owner = false; | ||
bool exposed_in_scene : 1; | ||
bool exposed : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like one of them is redundant. Wouldn't it be possible to infer exposed
from exposed_in_owner
and exposed_in_scene
?
Hey, have you manage to pull this off? |
Updated 11/1/2024
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.
expose parts of a scene (such as the hand bone of a character for equipping).
Note
Important
The use of unique names has been removed from this PR (#84018 (comment)) as there were too many issues with it, once #86960 is merged this PR should function like originally planned
Example
For a simple scene like the following, we expose the Sprite2D, the resulting tscn looks like this:
In another scene we instantiate this simple scene and override the exposed node's rotation property and add a child node to the exposed node. We also modify the color of the exposed node to orange
.tscn with this pr using exposed nodes:
.tscn with editable children and doing the same thing:
[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") + [editable path="scene_0_instance"]
Sample Project
TODO
I think that this pr addresses the following proposals: