So, I have a little bit of an issue that I can't exactly wrap my head around.
So, I have a base class called Property, and I have a lot of classes that derive from that one, like IntProperty, ColorProperty and so on. Now, I also have a few of them that are of the enum type and currently they are all separate classes. I'd like to make it a generic class but here's the issue with this:
In a different part of the code I need to handle all of them. Keep in mind I can't use virtual functions for this (I'm doing something with the UnityEditor).
Currently, I have a function that takes a Property as a parameter and then I do this for all types that derive from Property:
if(property is IntProperty) { IntProperty intProperty = property as IntProperty; intProperty.theValue = specific_int_function(); } That specific_int_function is the same for all enum values privided I have the T from a generic.
Ideally I'd like to do something like this (pseud-ish code):
(using T) { if(property is EnumProperty<T>) { EnumProperty<T> enumProperty = property as EnumProperty<T>; enumProperty.value = (T)my_enum_value_function(typeof(T)); } } Any idea about how I could make all this code nicer?
Hopefully I provided all the relevant information.
Edit:
It's not so much that I can't use virtual functions in those classes but I can't call any of the specific functions in that particular file. I have 2 compilation groups and only one can access those functions (EditorGUI functions for people who know what I'm talking about)
Regards, Lorin
Property<T>and createIntProperty:Property<int>,SomeEmumProperty<SomeEnum>,SomeOtherEnumProperty<SomeOtherEnum>types? Or you want just instantiate properties this way:var intProperty = new Property<int>(name, value);?