Unique ID Node

A custom Godot node that generates a unique ID to be concatenated to, or replace the parent node's name.

This node can be added as a child of an existing node. The parent node will then have its name either concatenated with the ID or replaced by the ID.

Features

  • Can generate 3 different length of unique ID: Short, Medium, Long.

  • Ability to concatenate the ID to parent name or replace the parent name.

  • Option to add a string separator when concatenating the ID.

  • Option to set the unique ID as persistent (saved to disk).

  • Automatically free this custom node after generating the unique ID.

How the idea started

"I was trying to search my node tree for a code-generated node, but I struggled because all the names were identical, labeled as @StaticBody@. I thought, why not retain the original name I gave each node and simply append some random characters to avoid any name clashes? And that's how the Unique ID node was born."

Here’s a video showcasing the initial development of the plugin.

Creating my first plugin in Godot

How to use

Adding the Node

After enabling this plugin, you can add the UniqueId node as a child of another node and it will add or replace a Unique ID to the parent node.

  1. Right-click on a node or press Ctrl+A.

    Adding a new node
  2. Type "unique" on the Search textbox of the Create New Node form to filter the node list and easily find the UniqueId node.

    Searching the UniqueId node
  3. Double-click the UniqueId node to add as a child of the node.

    UniquId node as a child node

Adding more than one UniqueId node will result in creating a sequence of Unique IDs. The IDs will either be concatenated or replace the parent name, which ever comes first.

Variables in Inspector

  • Length: The length of the unique ID to generate.

    • Short: When selected, the node will generate a 4 hexadecimal ID (8 characters).

    • Medium: When selected, the node will generate an 8 hexadecimal ID (16 characters).

    • Long: When selected, the node will generate a 16 hexadecimal ID in UUID format (36 characters including dash).

  • Separator: The string separator between the original node name and unique ID. Not used when Replace Original is true.

  • Enabled: Property to enable/disable the node.

  • Replace Original: When enabled, the parent's name is replaced by the generated unique ID.

  • Persistent Id: When enabled, the unique ID is saved in disk along with the object's instance ID. The file that stores the instance ID to unique ID mapping is saved in user://persistent.ids.

To save the unique IDs, call PersistentId.save_ids(), preferably in the _ready function of the root node.

To remove the unique ID from the list in the persistent.ids file, disable the Persistent Id option.

Examples

Without using the UniqueId node.

When using the UniqueId node.

Easier to search and filter!

More Screenshots

UniqueId inspector panel
UniqueId documentation

Last updated