title: Cast to type from Type variable
body: <p>I use Unity. I have an</p>
  
  <pre><code>abstract class A {}
  class A1 : A {object someField;}
  class A2 : A {object someField;}
  </code></pre>
  
  <p>I have a CustomEditor where I create instances of A1/A2 with reflection (I need an ability to add new classes derived from A)
  But there is a problem: if I use Activator like </p>
  
  <pre><code>Type chosenType = ChooseType(); //ChosenType can be A1 or A2
  A newObj = (A)Activator.CreateInstance(chosenType)
  </code></pre>
  
  <p>Unity doesnt serialize that objects (because it serialize objects as (A) but not as (A1) or (A2))
  I want to cast like </p>
  
  <pre><code>(chosenType)MyObj
  </code></pre>