Open sschellhoff opened 5 years ago
Why do you want to set such name though? @
is used by the engine internally to indicate nodes that were instanced without being given an explicit name, i.e. we don't actually care about their name. @
is thus a reserved symbol so that you know that nodes with a @
have all been created this way at runtime.
Well, just name all your instances you care for in unique way so that on the same level of the tree there is no duplication. This way you will now how to access each instance. I use that to save and restore from/to json.
BUT there is no easy to find documentation on which symbols I can safely use in instance names. The reason I ask about this is sometimes I need annotations for objects to which I add special handling (during import or runtime). For example all names ending in _spawn are spawn points and get attached script. But also I need to specify settings so that to select what in particular to spawn and other things. So I want to have some structure of name with separators. Using some characters would be nice to make that expressive. For example having something like "char_spawn#role=gplayer#team=1#group=spawn#id=10" would be nice as there is no other nice way to produce annotations in 3D software for engine to use.
Ran into this particular issue when writing a save system, took a while to understand what was happening too. The @ gets serialized just fine, but breaks things down the line when you try to use the name or node path for something (like parenting other nodes) as the @ gets silently stripped, leaving you none the wiser. I guess the proper workflow is to explicitly name all the instanced nodes that get used this way, but would've still been nice to know...
hi, anyone try to save the connections between GrpahNode to Json? i try a lot, still can't done, can any one help? (i can save the GraphNode size, position, and etc, but can't save the connections), thanks!
@xukongwen Please ask support questions on one of the other community channels, not here.
BUT there is no easy to find documentation on which symbols I can safely use in instance names.
Ideally we would use something like XID_Continue (see this and click category search), not sure what Godot currently does (personally I've only ever used English letters and numbers for node names).
Also @ can be in imported files. There should be some name filter functions in API to create safe names.
On Thu, Sep 24, 2020 at 9:36 AM Aaron Franke notifications@github.com wrote:
BUT there is no easy to find documentation on which symbols I can safely use in instance names.
Ideally we would use something like XID_Continue (see this https://unicode-lookup.netlify.app/ and click category search), not sure what Godot currently does (personally I've only ever used English letters and numbers for node names).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/27608#issuecomment-698145261, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABPU37OORMAWARUQ6ZHATSHLSFVANCNFSM4HDCTTCA .
I run into this problem making a save system for color palette generation app using GraphNodes and connections are made knowing the names. This symbol shouldn't be there if it's not allowed to be used naming nodes in runtime. Either remove practice from the engine side or give access to use it. Because of that, I'm forced to do a workaround:
func _ready()->void:
name = name.replace("@", "")
BUT there is no easy to find documentation on which symbols I can safely use in instance names.
Quotes from the current docs:
String.validate_node_name()
Returns a copy of the string with all characters that are not allowed in
Node.name
removed (.
:
@
/
"
%
).
Node.name
The name of the node. This name is unique among the siblings (other child nodes from the same parent). When set to an existing name, the node will be automatically renamed.
Note: Auto-generated names might include the
@
character, which is reserved for unique names when usingadd_child()
. When setting the name manually, any@
will be removed.
Node.add_child()
If
force_readable_name
is true, improves the readability of the addednode
. If not named, thenode
is renamed to its type, and if it sharesname
with a sibling, a number is suffixed more appropriately. This operation is very slow. As such, it is recommended leaving this tofalse
, which assigns a dummy name featuring@
in both situations.
I think the solution to this issue is to add cross-references (and possibly duplicate the list of prohibited characters into the Node.name
description).
Related:
This is especially apparent when collision shapes are created from Mesh Instance. These will start with @ but if we click to rename and press Esc, it'll change _ with no way to go back.
Godot version: 3.1
OS/device including version: Arch linux
Issue description: If you make multiple instances of the same nodetype, godot names the first instance after the node type and the other ones are prefixed with an @ and suffixed with an @ and a number. For example, if you create two Nodes of type GraphNode, the first instances name is "GraphNode" and the seconds name is "@GraphNode@288" or something like this. If you want to rename an instance and it does include an @, the @ gets discarded.
This is problematic if you want to save and load node data and node-connections.
Steps to reproduce: Make an GraphEdit, attach a script to it. In the script, create an instance of GraphNode and add it as a child. Set it's name to "@GraphNode@100". After that, print the name of the nodes instance. The name is "GraphNode100" and not "@GraphNode@100"