godot: Using class_name in a newly created script does not register it in the node creation dialog, if under addons/ (unless part of an enabled editor plugin)

Godot 3.1.1 Windows 10 64 bits

I suspect there is a scenario where it doesnt get registered at all. I was writing a new prototype this evening and the script still hasn’t registered.

Here is what I remember doing:

  1. Create a new project (no new scene)
  2. Create a subfolder addons/zylann.scatter/
  3. Right-click in the FileSystem dock and choose “New Script” into that folder
  4. Write the following (I wrote it by hand so might have had a few errors while doing so, but the end result was the same):
tool
class_name Scatter3D
extends Spatial

var _scenes = []

func _ready():
	# TODO Temporary test
	_scenes.append(load("res://props/placeholder_tree.tscn"))
  1. Save the script (still no scene in the project, I don’t use the default Ctrl+S, instead I save the script only)
  2. Create a new scene, open the node creation dialog, search for Scatter: it’s nowhere to be found, despite the class name being recognized by the script editor and saved in project.godot.

Even after restarting the editor, the node can’t be found. No particular messages in the console. Did I miss something obvious? image

Here is the project, apparently you should be able to see directly what happens, since restart doesnt fix it: Scatter.zip

Edit: It would seem any script I create under addons/zylann.scatter/ never get registered, but they do if I they are under the project root Oo According to TheDuriel it’s intented. Registration works in other systems, just not in the node dialog. I guess it’s because plugins can be enabled/disabled, so it would make sense for them to no longer clutter the dialogs. However, it’s not documented…

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 4
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Classes registered in a disabled plugin should not be available. If they’re currently only unavailable in the Create New Node dialog, but still registered in the global namespace, that’s the bug which needs to be solved.

So I have an Addon on the asset store and I want the class_name to appear in the Add Node dialogue. How am I supposed do make this happen? Do I ignore the convention of using addons folder? Do I need to turn my asset into a plugin so I can enable it?

Things in the addons folder that are not plugins should be enabled by default to make this simpler.

edit: figured it out with plugin config and (basically empty) plugin script - still seems a little unintuitive

I can confirm this on 3.2 stable.