Skip to content

Nodes with scripts added via add_custom_type without matching class_name cannot be added to the tree since 4.6dev5 #114349

@hrharkins

Description

@hrharkins

Tested versions

  • Reproduced in 4.6.beta2
  • Reproduced in 4.6.beta1
  • Reproduced in 4.6.dev6
  • Reproduced in 4.6.dev5
  • NOT reproduced in 4.6.dev4 (example works here)
  • NOT reproduced in 4.6.dev3 (example works here)
  • NOT reproduced in 4.5.1-stable (example works here)

System information

Godot v4.6.beta2 - Windows 10 (build 19045) - Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce 940MX (NVIDIA; 32.0.15.6636) - Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 threads) - 15.86 GiB memory

Issue description

The inspector/editor won't create nodes from add_custom_type even using the steps in https://docs.godotengine.org/en/latest/tutorials/plugins/editor/making_plugins.html#a-custom-node -- it seems to require class)_name of the exact same name as add_custom_type.

Steps to reproduce

Image
  • Result:

    • The inspector will not allow "Create" to execute but no error is present.
  • Expected Result:

    • A node of "My Button is created.
  • Adding a class_name in my_button.gd of the exact name allows the node to be created, but this seems to defeat the purpose of add_custom_type.

Minimal reproduction project (MRP)

plugin_test_2025-12-26_10-52-31.zip

Key code areas:

func _enter_tree() -> void:
	# The exampole (an anonymouse class) doesn't work.
	add_custom_type(
		"MyButton", 
		"Button", 
		preload("my_button.gd"), 
		preload("res://icon.svg")
	)
	# Having the name == class_name works, but defeat's add_custom_type's 
	# purpose.
	add_custom_type(
		"NamedMyButton", 
		"Button", 
		preload("named_my_button.gd"), 
		preload("res://icon.svg")
	)
	# Using add_custom_type to provide aliases also doesn't work.
	add_custom_type(
		"AltNamedMyButton", 
		"Button", 
		preload("alt_named_my_button.gd"), 
		preload("res://icon.svg")
	)

my_button.gd (from Godot docs example):

@tool
extends Button


func _enter_tree():
	pressed.connect(clicked)


func clicked():
	print("You clicked me!")

named_my_button.gd (with class_name makes inspector allow Create):

@tool
class_name NamedMyButton extends Button


func _enter_tree():
	pressed.connect(clicked)


func clicked():
	print("You clicked me!")

alt_named_my_button.gd:

@tool
class_name XNamedMyButton extends Button


func _enter_tree():
	pressed.connect(clicked)


func clicked():
	print("You clicked me!")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Bad

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions