- Home /
Question by
Dorscherl · Oct 26, 2021 at 04:32 AM ·
script.inspectorserializationtypeserializefield
Select a type from the inspector
To explain further, I want to be able to select from a dropdown of types in the inspector and serialize it.
public abstract class FooParent {
public string parentValue;
public abstract void SomeMethod();
}
public class Foo : FooParent {
public float fooValue;
}
public class Bar : FooParent {
public int barValue;
}
public class FooBar : FooParent {
public string someString;
}
So those would be the types I want to select from to serialize if I were to have
public class SomeBehaviour : MonoBehaviour {
//some base type
public FooParent someFooType;
//or list
public List<FooParent> fooTypeList;
}
This way I can choose what child type, I want to serialize and assign values accordingly. My use case is to assign ability effects from the inspector.
Comment