content

Consider an enabled plugin with the following script:

# res://addons/coloring/swatch_ref.gd
class_name SwatchRef
extends Resource

@export var swatch_key: String
@export var default_color: Color
@export var use_swatch: bool

func get_color() -> Color:
	if use_swatch:
		# TODO: Lookup the color using the swatch key
		return default_color
	else:
		return default_color

And in the root of the godot project with that plugin:

# res://test.gd
@tool
extends Node3D

@export var swatch_ref: SwatchRef = SwatchRef.new()

func _process(_delta) -> void:
	print(swatch_ref.default_color) # Works
	print(swatch_ref.get_color()) # Doesn't work

You will always get the error res://test.gd:8 - Invalid call. Nonexistent function 'get_color' in base 'Resource (SwatchRef)'. while in the Editor (it will work in play mode).

This is because SwatchRef does not have the @tool annotation, meaning that it won't have code that can be run in the editor and the methods won't be added to the class.

See:

meta

created:

backlinks: @tool script says function does not exist when it does

commit: 74cb7704