I want to use Generic type definitions in the Unity Editor and cannot (yet) update to Unity 2020.1 which natively supports this. The workaround is to define a non-generic class that extends the generic class. However, when I try to override a base class property, with a defined class which is basically a named version of the generic property, the compiler reports both types to be incompatible. Since this description is quite ... generic ... here is some code to illustrate my issue:
class Property<T> { }
class BaseClass<T>
{
public virtual Property<T> Property { protected get; set; }
}
class StringProperty : Property<string> { }
class SubClass : BaseClass<string>
{
public override StringProperty Property { protected get; set; }
}
SubClass.Property': type must be 'Property<string>' to match overridden member 'BaseClass<string>.Property
SubClass.Property is basically Property<string> but I don't know how to communicate this to the compiler.