title: Unity: Assign instance of abstract object in the inspector
body: <p>In my game, I have a magic system that uses a command-pattern to store the steps. How can I assign an abstract command not derived from <code>MonoBehavior</code> or <code>ScriptableObject</code> in the inspector (or just not hard-coding it)?</p>
  <p>Below I have the minimum example, note that <code>SpellCommand</code> does not derive from <code>MonoBehavior</code> nor <code>ScriptableObject</code>.</p>
  <pre class="lang-csharp prettyprint-override"><code>public abstract class SpellCommand {
      public SpellCommand (int power = -1) {
          this.power = power;
      }
      public abstract void Cast();
  }
  </code></pre>
  <p>And here is what a spell might look like</p>
  <pre class="lang-csharp prettyprint-override"><code>public class SampleSpell : SpellCommand {
      public SampleSpell(int power) : base(power: power) { }
  
      public override void Cast() {
          Debug.Log(&quot;Sample Spell Cast&quot;);
      }
  }
  </code></pre>
  <p>And finally a <code>MonoBehavior</code> to invoke it</p>
  <pre class="lang-csharp prettyprint-override"><code>public class TestSpellInvoker : MonoBehaviour
  {
      public SpellCommand testSpell;
  
      void Start() {
          testSpell.Cast();
      }
  }
  </code></pre>
  <p>Since I know Unity doesn't support serialization of abstract classes not derived from <code>MonoBehavior</code>, I wrote my own inspector script to assign and display the contents of <code>testSpell</code> but whenever I enter play mode, it seems to be nulled out.</p>
  <p>I've considered removing all polymorphism and simply using a large <code>Enum</code> to represent subclasses, but that would introduce a ton of complexity and it feels very much against the spirit of C# and OOP. I've also considered using <code>ScriptableObject</code>s, but that would require (in my case) having potentially thousands of <code>ScriptableObject</code> instances saved as files that I would then have to wrangle (although that being said my knowledge of <code>ScriptableObject</code>s is pretty elementary so I might be missing something).</p>