ValksGodotTools / Template

Template to be used for all Godot 4 C# starting projects
MIT License
66 stars 5 forks source link

Cannot create console commands in abstract classes #13

Closed valkyrienyanko closed 8 months ago

valkyrienyanko commented 8 months ago

Describe the Issue

Cannot create console commands in abstract classes

Exception

E 0:00:04:0457   :0 @ System.RuntimeType+ActivatorCache..ctor(System.RuntimeType ): System.MissingMethodException: Cannot dynamically create an instance of type 'SpaceGame.Ship'. Reason: Cannot create an abstract class.
  <C++ Error>    System.MissingMethodException
  <C++ Source>   :0 @ System.RuntimeType+ActivatorCache..ctor(System.RuntimeType )
  <Stack Trace>  :0 @ System.RuntimeType+ActivatorCache..ctor(System.RuntimeType )
                 :0 @ System.Object System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
                 UIConsole.cs:296 @ System.Object SpaceGame.UIConsole.GetMethodInstance(System.Type )
                 UIConsole.cs:143 @ Boolean SpaceGame.UIConsole.ProcessCommand(System.String )
                 UIConsole.cs:202 @ void SpaceGame.UIConsole.OnConsoleInputEntered(System.String )
                 LineEdit.cs:1377 @ void Godot.LineEdit.TextSubmittedTrampoline(System.Object , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& )
                 DelegateUtils.cs:62 @ void Godot.DelegateUtils.InvokeWithVariantArgs(IntPtr , System.Void* , Godot.NativeInterop.godot_variant** , Int32 , Godot.NativeInterop.godot_variant* )

Question

Can this restriction be lifted somehow?

valkyrienyanko commented 8 months ago

https://stackoverflow.com/questions/60632841/system-missingmethodexception-cannot-create-an-abstract-class