Engine.is_editor_hint() and instantiating 'abstract' classes

Godot Version



I’m trying to write an addon that uses the EditorResourcePicker in a popup.

When trying to test run the scene I get errors complaining about it being abstract. While this makes sense, I can actually instantiate it in the editor. Which also, sort of, makes sense. My background is in Python, so I’m used to the dynamic typing.

What I’m trying to figure out is, why am I still getting the error even when the line is guarded with Engine.is_editor_hint()?

For example, this breaks and the debugger opens when running the scene, but not when the plugin is run in the editor:

	if Engine.is_editor_hint():
		var picker = EditorResourcePicker.new()

What am I missing?

That looks good. I am kind of shell-shocked by godot. I always assume the worst. Maybe:
If EditorResourcePicker: var picker = EditorResourcePicker.new()

Wish I could help you more. You can use my code which uses that class:

EditorResourcePicker only exists in the editor. When you run the game it does not exist but GDScript will still check if the class exists or not.

Try this:

if Engine.is_editor_hint():
	var picker = ClassDB.instantiate("EditorResourcePicker")

Yep, that worked! Thanks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.