Add script class categories to EditorInspector.
Closes godotengine/godot-proposals#109.
There isn't an icon showing beside DerivedB, but that is a bug that is unrelated to the mentioned Issue.
extends Node
class_name DerivedA
export var health := 0
export var can_heal := true
extends DerivedA
class_name DerivedB
export var power := 0
export var duration := 0.0
export var superpower := @""
Here is an updated version that does away with the "Script Variables" section entirely and which always uses the script class name (if it's available) or the file name (capitalized, without spaces) so that they usually appear as a valid identifier (unless it's a filename that starts with a number or something).
In the example below, I have a non-script-class script in between two script classes:
extends Node
class_name DerivedA
export var health := 0
export var can_heal := true
extends DerivedA
export var power := 0
export var duration := 0.0
export var superpower := @""
extends "res://derived_b.gd"
class_name DerivedC
export var experience := 0
export var level := 0
Okay, here is the same code, but now I've changed it to show the file name and I went ahead and updated the icon rendering code so that it will fetch the most recent script class icon / base type icon PER individual script in the hierarchy.
Note that the code now anticipates that if it is a category, and the category's name does not match an existing ClassDB or ScriptServer record, AND the hint_string
contains a valid file path, then it will attempt to load that file path as a script so that it can load the script and fetch the appropriate icon from its information.