Jump to content

Support for abstract classes in ComponentSystem


photo

Recommended Posts

Posted

Hi UNIGINE-Team,

it would be nice if the current ComponentSystem would support abstract classes so the user can't be attached that classes to any nodes/surfaces in order to allow a more convenient code paradigm. When currently using somethin like "public abstract class MyClass : Component", the dotnet.exe in the editor crashed, VS-console will give you a little bit more info:

1>CSPropertyGenerator started
1>Unhandled exception. System.MissingMethodException: Cannot dynamically create an instance of type 'MyAbstractClass'. Reason: Cannot create an abstract class.
1>   at System.RuntimeType.ActivatorCache..ctor(RuntimeType rt)
1>   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
1>   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
1>   at System.Activator.CreateInstance(Type type)
1>   at Unigine.ComponentClassData.SaveProperty(String file_name)
1>   at Unigine.ComponentSystem.SaveProperties()
1>   at UnigineUtils.CSPropertyGenerator.Main(String[] args) in D:\BA\work\16e2ac2576e002c0\source\csharp\tools\CSPropertyGenerator\main.cs:line 108

Maybe adding at least an short "type.GetTypeInfo().IsAbstract;" would deal with the crash at the moment.

Best

Christian

×
×
  • Create New...