Jump to content

Abstract Component


photo

Recommended Posts

Posted

Hello, I'd like to ask if its possible to create a abstract C# component class for inheritance only? I'm new to Unigine so I might be missing something.

Here is a example of what I want to achieve:

public abstract class MyComponentBase : Component {
  	
  public MyComponentBase(...) { ... }
  
  protected virtual void Init() { System.Console.WriteLine("Hello from component base class!"); }
  
}

public sealed class MyComponent : MyComponentBase {
  
  public MyComponent() : base(...) { ... }
  
  protected override void Init() { base.Init(); System.Console.WriteLine("Hello from my component!"); }
  
}

 

Attempting to build the example results into the following build error: "System.MissingMethodException: Cannot create an abstract class."

Is there a attribute I am not aware of that would prevent it from attempting to instantiate the abstract component during build process? Thanks.

Posted

Hi, SystemOverlord!

At the moment, you can't use abstract class as a component. I've created new ticket and we'll try to implement this feature in the next release (2.15).

Best regards,
Alexander

  • Like 1
×
×
  • Create New...