- Home /
How to modify child class's enum depending on value of parent enum in custom editor,Custom editor to modify nested classes enum options
I've got a class with an enum and a list of objects which contain enums themselves and what I want is to select a value from the top level enum drop down, and then all the options in the nested enums are then updated. code here
public class AttackObject : ScriptableObject
{
public PlayerAttack.AttackType attackType; // enum
public List<SkillBonus> skillBonuses = new List<SkillBonus>();
}
public class SkillBonus {
public PlayerAttack.BonusId id;
}
What I'm struggling with is trying to create an enum with custom options in the children of a list. I've also tried looking at propertyDrawers for the child class but I don't know how to access the enum value of the parent.
Answer by logicandchaos · Feb 23, 2021 at 02:00 PM
Use OnValidate() make it so that the enums to available are based on what the top enum is set to. So maybe a switch statement in your OnValidate() switch(topEnum){} and then in the cases you put the code to select which lower enums you have access too.