Node Referencer

An asset by SanderVanhove
The page banner background of a mountain and forest
Node Referencer thumbnail image
Node Referencer thumbnail image
Node Referencer thumbnail image
Node Referencer image holder but it is empty

Quick Information

0 ratings
Node Referencer icon image
SanderVanhove
Node Referencer

Easily add node references to scripts and copy the variable name to your clipboard.1. Select one or more nodes. There will be a dropdown menu in the scene toolbar if the plugin detects that one of the node's parents has a script. The plugin will scan recursively up the tree.2. Select the parent to which you want to add the reference.3. Select the last option to copy the last created reference's variable name.4. Reload the parent script by closing it and reopening it. For some reason, I can't get it to reload automatically.5. Now you can use that variable.

Supported Engine Version
3.4
Version String
1.0.3
License Version
MIT
Support Level
community
Modified Date
2 years ago
Git URL
Issue URL

Node Referencer

Godot plugin to easily add node references to scripts and copy the variable name to your clipboard.

Example

onready var _animated_sprite: AnimatedSprite = $AnimatedSprite

README Overview Gif

Usage

  1. Select one or more nodes. There will be a dropdown menu in the scene toolbar if the plugin detects that one of the node's parents has a script. The plugin will scan recursively up the tree.
  2. Select the parent to which you want to add the reference.
  3. Select the last option to copy the last created reference's variable name.
  4. Reload the parent script by closing it and reopening it. For some reason I can't get it to reload automatically.
  5. Now you can use that variable.

README Usage

Features

  • Add a reference for a node to one of its parents' script.
  • Add references for multiple nodes at once.
  • Copy the name of the last made reference.
  • Makes sure the reference has the appropriate class. Works with custom class_names and extends.
  • Prevents duplicate references.
  • Enumerates variable names when there is a conflict in naming.
  • Sorts references alphabetically.

Variable name convention

The plugin will take the name of the node, convert it to snake case and put a _ in front to show it's a private value.

Example

AnimatedSprite -> _animated_sprite

References code block

This plugin will create a code block within the parent script to group all its references. This block looks like this:

### Automatic References Start ###
onready var _animated_sprite: AnimatedSprite = $AnimatedSprite
onready var _kinematic_body_2d: KinematicBody2D = $KinematicBody2D
onready var _ray_cast_2d: RayCast2D = $AnimatedSprite/RayCast2D
### Automatic References Stop ###

You can rename variables, to prevent duplicate references the plugin looks at the path.

You can change the location of this block of code. As long as the ### Automatic References Start ### and ### Automatic References Stop ### are unchanged.

FAQ

Can I relocate the reference block?

Yes, as long as it has the same structure.

Can I change the variable names?

Yes, rename away!

I changed the node's position in the scene, what now?

You can do one of two things:

  • Remove the reference from the reference code block and add it again using the plugin.
  • Manually alter the path in the reference code block.

Why didn't you use exported NodePaths?

Because NodePaths bug out some times, in my experience.

Why do I have to close and reopen the parent's script?

The script gets saved to disk correctly, but Godot holds a cache that only get invalidated after closing it. If you know a workaround please let me know.

Easily add node references to scripts and copy the variable name to your clipboard.

1. Select one or more nodes. There will be a dropdown menu in the scene toolbar if the plugin detects that one of the node's parents has a script. The plugin will scan recursively up the tree.
2. Select the parent to which you want to add the reference.
3. Select the last option to copy the last created reference's variable name.
4. Reload the parent script by closing it and reopening it. For some reason, I can't get it to reload automatically.
5. Now you can use that variable.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Node Referencer icon image
SanderVanhove
Node Referencer

Easily add node references to scripts and copy the variable name to your clipboard.1. Select one or more nodes. There will be a dropdown menu in the scene toolbar if the plugin detects that one of the node's parents has a script. The plugin will scan recursively up the tree.2. Select the parent to which you want to add the reference.3. Select the last option to copy the last created reference's variable name.4. Reload the parent script by closing it and reopening it. For some reason, I can't get it to reload automatically.5. Now you can use that variable.

Supported Engine Version
3.4
Version String
1.0.3
License Version
MIT
Support Level
community
Modified Date
2 years ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers