-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Implement Scene Unique Nodes #60298
Implement Scene Unique Nodes #60298
Conversation
273c98e
to
e6051c9
Compare
How does this work if I have a player scene instantiated in the main game scene, and I mark the player unique (from the main game scene, not within player scene)? |
@Zireael07 This is not what this feature is for. If you want to do this, just add the player to a group (player) and retrieve it from there. This is for code that needs to fetch nodes within the same scene, but this scene can be instantiated multiple times. |
Ah, ok. So it should likely not allow me to try to set something that's instantiated/foreign as scene unique, if it doesn't already? (Haven't looked at the changes) |
e6051c9
to
47522e9
Compare
I feel the RMB context menu is a good place for this option and don't think it should get a toggle button in the scene panel like visibility. Reasoning:
Although the indicator that a node is scene unique can probably be improved. Btw, does this also resolve godotengine/godot-proposals#996 ? |
@h0lley It can always work like the lock button, whereas its only visible when enabled, and if you click it it gets disabled. |
Nevermind. I thought I was reading a proposal. 😅 I'll check the code later. |
I still think this is going to be abused as a replacement for |
AnimationTrack might want to indicate that it is a unique path. However, there is the problem of not being able to handle the case of a unique path that has a non-unique path as its parent, so there is no need to hustle to work around that. It seems to me that we will need to add an option to import animations as unique paths later in the AnimationLibrary importer, etc., but that would be outside the scope of this PR. |
this would not be abuse - it's part of what this feature is intended for. doing this is completely fine. it would have no relevant impact on performance when using literal NodePath syntax: it can have an impact on performance when get_node() is being passed a String that still needs to be converted to NodePath, but that's a different issue about making people aware about that fact (or making the GDScript compiler smarter about it). |
@TokageItLab Right, this should be added to the importer in a subsequent PR I guess |
47522e9
to
c16ca88
Compare
@h0lley Okay, used the icon system we already have, feels more consistent now. |
I think it looks good, although if we want to do it like that, I reckon the option should be put in the top tool bar - closeby Then there would be no need to have this outlier toggle button in the RMB context menu. |
@h0lley The toolbar is for options related to the viewport, which is not the case here. Other options that appear as icons (whether there are connected signals, as an example) are not there either. I think it should be good as is for now, we can see after merged if better ideas come up or if its good enough. |
This is a welcome change. As a C# user, this is a very tedious part of setting up and changing a scene, so I appreciate a more terse syntax. |
@markdibarry yup, that should work fine in C# |
Is this feature limited to It would be nice to have something like |
|
@timothyqiu alright, fixed the first case. The second one will probably need a bit more doc when tutorial is written. |
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.
Looks good.
44444cb
to
e5a2038
Compare
Implements godotengine/godot-proposals#4096 * Nodes can be marked unique to the scene in the editor (or via code). * Unique nodes can be accessed via the **%** prefix at any point in the path. From that point in the path (depending on whether the scene of the path is), the unique node will be fetched. * Implementation is very optimal, as these nodes are cached.
e5a2038
to
8580f37
Compare
Thanks! |
problem with getting reference in grandchild node in 3.5beta:
access to turn_manager from minimap returns null
so, better description would be: any node within that scene, but doesn't grandchild and lower levels? edit: added editor version. |
@boruok sounds like you may want to file a bug report. Make sure to include detailed information that others can use to reproduce the issue you are facing. |
This is not a bug, but likely a misuse of the feature. Show your full scene and how you try to access the nodes. |
@KoBeWi, hmm, i actually find what was wrong: saved branch scene usage, if i make that branch make local reference works, should i open issue? |
@boruok This is intended. They are two different scenes after you saved the branch. |
I don't know if this is the best place to say this or if it should be a new proposal, but I think it should be harder to disable the '%' prefix than simply clicking it, because sometimes we just want to select the node in the scene tree and we unintentionally click the '%' and disable it. All the times that it happened to me I saw it happening, but there may be cases when we don't see it and it causes errors on the code when trying to get those nodes by their unique names with the '%' prefix. And it is annoying having to enable it again every time it happens. I think it should be as "difficult" to disable it as it is to enable it, so we don't disable it unintentionally. |
This isn't the place for this indeed, please open a discussion or proposal for it, this is a closed PR that has been inactive for over a year so this isn't the place for feedback |
Implements godotengine/godot-proposals#4096
Screenshots:
To make any node unique, this new option was added:
Which results in the node being marked with an icon:
This allows the node to be accessed from anywhere within the scene (note, $ Syntax not updated, required GDScript changes as a follow-up PR):
If more than one node is made unique with the unique name, a warning will be shown:
Note Backporting this PR to Godot 3.x should be relatively easy if anyone is interested, it does not rely on anything specific from master branch.