-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Make the "internal node" feature more accessible #4265
Make the "internal node" feature more accessible #4265
Comments
you could set metadata |
Oh, i didn't know about metadata, thanks for the hint! Glad there is a way to do it, but still, i think this method is hidden enough to get overlooked or missed (like i did), so the issue still hold. For context, the "internal node" feature modify most of the node related functions. Now the
Most of the node related functions now ask for a boolean flag called "include_internal" to specify if internal nodes should be taken into account. For example, using |
I believe a better implementation would be using methods over direct property access, as it would change the SceneTree which is an action: |
Building encapsulated GUI widgets with the editor is tricky, setting internal node from the editor could help removing a lot of code. |
The current implementation uses the order of child nodes, which is highly efficient, how would this proposal handle this, how would it accomplish changing the status of the node? |
The proposal could use the current re-order of the child nodes upon call to IMHO, if the editor could allow setting the internal mode of a Node, that would:
|
Can you elaborate on this? From my (non-expert) point of view - if the implementation relies entirely on the current API and only modification is a new property to Node (set upon call to With hindsight I realize my wording in the previous message is confusing, as I meant for point 4. to retrieve internal nodes only, not filter them out. Apologies. |
Edit: My bad I misread it as a workaround in the editor The only missing part really is that you can't access if a node is internal or not from script, you can do everything else with script and easily, though the ability to move from internal to non-internal would be useful it's kind of potentially messy, and I'm honestly not sure what the use case would be for changing internal status Extracting only internal children could also be done effectively in code, but I don't see much reason for that specific use |
So, there's arguably good reason to expose the But what is the use case for changing internal mode of a node specifically? What situation would this be required that means that you can't just use the technique of swapping it But more importantly, for the OP: The nodes that are in the tree in the editor are only supposed to be there if they are part of the scene file, I think there's a confusion over what internal nodes are and how they work here To clarify: What situation do you have where it is relevant for a node to know if it is internal? Are you sure you really need to know that? |
@AThousandShips thanks for the elaborated response, much appreciated. |
Working on UI/Tooling in the last couple of months has shown me, how incredible this feature actually is! I really hope such a simple change gets implemented soon. It's not, that it isn't doable without it, it's just, this is a HUGE QoL improvement to make code more readable and clean up the editor of unnecessary junk nobody wants to see! |
related: |
Thought I would share a quick C# extension method that will return if a node is Internal. This works because GetChildren() does not return internal children by default. public static bool IsInternal(this Node node) {
Node parent = node.GetParent();
if (parent == null || parent.GetChildren().Contains(node))
return false;
return true;
} |
This is cool and all but I'm sorry to burst your bubble...
You can already do that with GDScript... |
Describe the project you are working on
I'm developing an RPG as solo developer using Godot 4 and i found the new "internal mode" feature very useful to add nodes that are supposed to not be moved/removed or to be handled by a specific node. Unfortunately i found some limitations i think they could be easily enough overcome to worth the invested effort and the usability gain.
Thanks in advance for the dedicated time reading this proposal.
Describe the problem or limitation you are having in your project
The new Godot 4 feature of internal nodes is very useful, it is possible to pass a flag on the
add_child
function of aNode
to set the child as internal. Unfortunately that's the only way to achieve that and there are cases where having only such option is limiting, for example:It is not possible to check if a node is "internal" or not, at least not easily: the only way i found is to check if such node is inside the parentas pointed out, it is possible to check the internal status of a node by looking into its metadata. Still i think an editor visible flag would be more intuitive solution.get_children(false)
; if it is not is "internal". This requires to iterate over all the children, that is not very efficient._ready()
function the "remove and re-add" method described in the first point to achive the goal.Describe the feature / enhancement and how it helps to overcome the problem or limitation
A simple solution could be to expose the internal mode of a
Node
as an enumerator, something that could be represented with GDScript as:The child
Node
will be moved accordingly when such variable is modified.If a child change its
internal_mode
fromINTERNAL_MODE_FRONT
toINTERNAL_MODE_DISABLED
, it will be now the first node among the normal ones.If a child change its
internal_mode
fromINTERNAL_MODE_BACK
toINTERNAL_MODE_DISABLED
, it will be now the last node among the normal ones.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
From the editor, a new member would appear in the
Node
section, allowing to select if a node should be considered internal or not; it would appear the same as exporting a normal enumerator.From the code it would be possible to change such state with something like:
Then the parent will react to such change and moves the child accordingly.
If this enhancement will not be used often, can it be worked around with a few lines of script?
With a simple structure like:
on the "ParentNode" such code is currently required:
Of course, the more nodes are required to be internal, the more code is required.
Is there a reason why this should be core and not an add-on in the asset library?
I think node related features should be core.
The text was updated successfully, but these errors were encountered: