Allow the user to enter the same Id for multiple GUI nodes

I often find myself having several nodes that does the exact same thing, but at different positions within the hierarchy. I might have a node that is used to position other nodes in a certain way or display a commonly occurring graphic asset. When building these kinds of scenes the Id needs to be unique, which I either do by coming up with elaborate names, or what I do nowadays, type a string of arbitrary characters at the end the Id. It works, but doesn’t look too great. Here’s an example:

one_of_many_hud_containers_1
    level_up_modal_reward_2_top_left_graphic
    level_up_modal_reward_2_top_right_graphic
    ...
one_of_many_hud_containers_2
    top_left_corner_noehyv
    top_right_corner_vosexo
    ...

In some cases this can be avoided by using templates. But working with several templates can be cumbersome as one scene is split over many files. Especially when I’m throwing together things to test or prototype I prefer to have everything in one file.

What I propose is to allow the user to enter the same Id for multiple nodes. Then during compilation or runtime append something to the node Id, much like how game objects created using a factory gets unique names. If the user should be able to access these nodes from the script, I guess other changes are needed. But most often I find that I never modify these types of nodes from the script anyway.

Hmm, your specific example makes me think that in such a case you’d use a single image and nine-slice it, but maybe it doesn’t always work to use nine-slicing. Perhaps leaving the node id blank could be an option and then an id would be assigned at runtime.

That suggestion of having id:s be undefined like @britzl says would be interesting. Internally they would always have an id like the “tree_clone” gives you a generated one (Much like factory), and if you define a “public id” that would open for “get_node” to be used. The question then is, how would the “clone_tree” index entries if which have no “public id”?

I think this would be a great change, as I often find myself in this position when cloning groups of nodes. Having to rename them and create “entry_1” things. There are a few quirks to figure out first tho :slight_smile:

1 Like

I was thinking if we should add a “Group” node type or similar, that doesn’t have an id, and not any graphics either. As @Adam_Westman points out, there are probably a few things to solve before considering this.

Sorry to necro this thread, but I recently hit this issue and it seems strange to have to have a unique node name within a tree, especially when you don’t even want to reference the node externally. I think most users would consider the node tree like a filesystem where folders create a “namespace”. If you want to use gui.get_node() on the node then the name should be unique unless the name contains a forward slash and is an absolute reference to the node?