C# EditorPlugin, Currently selected nodes ignore script type
Created by: DeathTBO
Godot version: 3.2
OS/device including version: Linux Fedora 31 x64
Issue description:
Normally when coding the Node "is the script". You can cast a Node as its script type. For example:
MyClass c = GetNode("path") as MyClass;
However when making an EditorPlugin this method doesn't work at all. This is null:
MyClass c = editorSelection.GetSelectedNodes()[0] as MyClass
Reproduce: Create a new project. Create a new CSharp script extending a Node. Attach it to a scene. Then create and enable a new CSharp EditorPlugin. Override _EnterTree and Connect to the OnSelectionChanged signal.
GetEditorInterface().GetSelection().Connect("selection_changed", this, nameof(OnSelectionChanged));
Get the CurrentSelection editorSelection.GetSelectedNodes();
Cast the selected Node as its script type or compare the node with the is keyword. It will return a null reference exception or false. When using GD.Print it will only show the base type.
This makes it impossible to interact with scripts attached to Nodes.
I also attached a project. Simply click the different Nodes and check the output. You can also view the EditorPlugin script in res://addons/Test/SelectionTest.cs
Project: TestSuite.zip