Open FractalDiane opened 2 weeks ago
Thanks!
This is really a Godot issue - once this is exposed there (or some other way to allow this is added), it should start working with godot-cpp.
I threw together PR https://github.com/godotengine/godot/pull/98929 which exposes the _create()
virtual method. I haven't tested it, and since I don't really know this API, I'm not sure this is right approach, but hopefully this could help get things started :-)
Godot version
4.3.stable
godot-cpp version
4.3.stable
System information
Windows 10
Issue description
Context I'm creating an editor plugin with GDExtension that involves working with .ink files, and I'm trying to create a syntax highlighter for it in pure C++. I'm creating and registering this highlighter class:
However, I cannot get any part of the highlighter to actually work; it shows up as an option in the syntax highlighters list, but it just shows up as Unnamed and doesn't actually provide any highlighting. (I tried putting prints in all three functions and none of them are even called)
What I think is the problem I looked into the Godot source code for
EditorSyntaxHighlighter
, and it has a method called_create
which is called whenever a highlighter is instantiated. Normally, it instantiates a baseEditorSyntaxHighlighter
and just tries to give it whatever script the object has:My class is a native derived class that has no script, so it seems like it's failing to find a script and just instantiating a default base
EditorSyntaxHighlighter
for me.However, looking at the source code for the derived
GDScriptSyntaxHighlighter
class, this class overrides the_create
function and just returns a ref to the derived class instead.This seems to be the solution to get a pure C++
EditorSyntaxHighlighter
with no script to work; however, this_create()
function is not accessible in GDExtension, so this seems to not currently be possible unless I'm missing another way of doing this.Steps to reproduce
EditorSyntaxHighlighter
and overrides the_get_name
functionEditorPlugin
class that registers this syntax highlighter_get_name
is not shown when selecting it in editorMinimal reproduction project
N/A