Can't get to the script (C# object) instance from EditorInspectorPlugin code
Servail opened this issue · comments
Godot version
4.1.rc3.mono.official [cdd2313]
System information
N/A
Issue description
Looks like EditorInspectorPlugin's virtual methods (_CanHandle() _ParseBegin() _ParseEnd() etc.) GodotObject parameter (@object) doesn't relate to C# script class instance at all.
In my other issue I realised that when you attaching a script to Node or Resource (which are GodotObjects), it kind of becomes the Type of that script (class).
Also according to this answer I just must cast GodotObject to the script Type. But it fails!
Maybe I'm being stupid (again?), but how to get to the "real" instance?
Steps to reproduce
- Open attached project
- Look in TestInspectorPlugin.cs
- Press "TEST" button in inspector
Checked everything I can think of; must print C# script class type somewhere, but don't!
Minimal reproduction project
I found it starts working as intended only with [Tool] attribute added to TestScript or TestResource! I think it's because C# class is not actually instantiated in editor by default. Then how Godot gets to script object's fields and serializes values?