Create custom UI

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AlexIva

Hello everyone!

I am trying to create custom CheckBox using this article Создание плагинов — Документация Godot Engine (4.x) на русском языке

I have created a file res://addons/rgCheckBox/rgCheckBox.gd:

tool
extends CheckBox
class_name rgCheckBox

func _ready():
	pass

I have created a file res://addons/rgCheckBox/custom_node.gd:

tool
extends EditorPlugin

func _enter_tree():
	add_custom_type("rgCheckBox", "CheckBox", preload("rgCheckBox.gd"), preload("icon.png"))

func _exit_tree():
	remove_custom_type("rgCheckBox")

The problems:

  1. I can not see rgChechBox in Editor control list
  2. When I try to enable this custom component in [Project] > [Project Settings…] > [Plugins] then I get the message
Unable to load addon script from path: 'res://addons/rgCheckBox/rgCheckBox.gd' Base type is not EditorPlugin.

As I understand in Godot script multiple inheritance is not supported (or is supported but I did not find this syntax) - so how can I inherit my custom component from EditorPlugin and standard UI component in the same time? Or what am I generally doing wrong?

Thanks in advance

:bust_in_silhouette: Reply From: Wakatta

Problem

You have set up your plugin configuration in custom_node.gd and as such this is what your plugin file should point to

Solution

In your plugin.cfg file change the line

script="rgCheckBox.gd"

to

script="custom_node.gd"

Notes

To prevent the error in future name your config file as plugin.gd or a naming scheme like
custom_node.gd
custom_plugin.gd