Is there a way to drag a Subclass onto a Field of the Super Type?

Hi There

I have a skill system and for better or worse I decided that I would create a list of these skills and attach the list to a persistent game object in the scene for easy loading and editing.

My skill looks a bit like:

[System.Serialize]
public class Skill
{
   public enum SkillType { None, Dagger, Shortsword, FireBolt, etc.... }
   public SkillType Skill = SkillType.None;
   public SkillHandler Handler = null;
}

The list would look something like:

public class SkillList : MonoBehaviour
{
   public List[] Skills = null;
}

and I then have:

public abstract class SkillHandler : ScriptableObject
{
   public abstract void UseSkill(Skill skill, Character character);
}

And perhaps:

public class WeaponSkill : SkillHandler
{
   public override void UseSkill(Skill skill, Character character)
   {
      // do something useful
   }
}

Having dragged my SkillList onto an object that persists throughout the game, I can see each skill I add, which is great and I can add the data required to manage each skill, but although I can see the SkillHandler, the inspector will not allow me to drag the subclassed WeaponSkill onto the field, which is decidedly frustrating.

I am happy to hear alternative solutions, but I’m really asking if this is possible, or for something grander than a switch statement that might provide an ‘elegant’ solution.

Thanks
Bovine.

Ha, this DOES work, it wasn’t working because it needs to be an instance of the handling class, which can be solved by dragging WeaponSkill onto an object and then dragging it onto Field.

However, that’s not necessarily the most elegant of solutions and really, the handlers don’t need to be instance methods… hmmmm re-think time maybe?