-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Expose Node::force_parent_owned()
to allow avoid duplicate nodes for plugin development
#9282
Expose Node::force_parent_owned()
to allow avoid duplicate nodes for plugin development
#9282
Comments
This is specifically for child nodes added outside of the constructor, to be clear, you can work around this by adding child nodes in the constructor, i.e. in Edit: This seems to be impossible right now at least, as the Exposing this could be dangerous, it could break and crash scripts by changing dependent data in built in nodes etc. |
This proposal is describing a fair issue. But the proposed solution does not feel right:
So, exposing a method explicitly designed to be used internally... so that the issue can be worked around, instead of addressing the original issue in the first place. Whatever its purpose is (as the name is fairly vague) it sounds like trouble to me. |
Not all internal nodes can be determined in constructor,
I'm not sure how this change led to the dangerous behavior you mentioned, it seem that Edit: I think the better way is give it a better name to expose it like @KoBeWi comment. If expose the controllability of |
Node::force_parent_owned()
to allow avoid duplicate nodes for plugin development.Node::force_parent_owned()
to allow avoid duplicate nodes for plugin development
Currently the logic for determining "internal" nodes is rather inconsistent. When dealing with instances, tbh this could use some re-thinking. We could maybe remove the parent owned hack and make the internal nodes more useful, that is, make them not duplicated when the parent is duplicated. I originally was opposed to that (godotengine/godot#84824 (comment)), but I didn't consider non-instanced nodes, where using |
For me this function is also quite important, since my plugin also has a problem with duplication |
I think this proposal can't be approved by core members. I don't know the true case in your plugin, here I just provide my solution to avoid this issue. For the solution in my Godot-DragonBones to solve this duplicate issue, I create |
Note that even though in the past some of us expressed this is not a good idea, alternatives to solve the same issue are very much welcome and worth looking into. |
Describe the project you are working on
Creating a DragonBone plugin by using GDExtension.
Describe the problem or limitation you are having in your project
I need to create an internal tree struct like this:
DragonBones (Node2D)
|-
DragonBonesArmature (Node2D)
DragonBonesArmature
is created byDragonBones
automatically, and need to be an abstract class to avoid created by users.But duplicate a node will duplicate its children, and duplicated a
DragonBonesArmature
node will failed because of it is an abstract class and can't be instantiated byClassDB
.In other words, I can't duplicate a
DragonBones
node in editor.Describe the feature / enhancement and how it helps to overcome the problem or limitation
If
Node::force_parent_owned()
is exposed, I can use it to avoid duplicate internal node, likeTileMapLayer::set_as_tile_map_internal_node()
.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Just bind it in _bind_methods().
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, it is impossible to change the duplicate logic in script.
Is there a reason why this should be core and not an add-on in the asset library?
Node duplication is core function.
The text was updated successfully, but these errors were encountered: