Is there any way to use AddComponent with a script in Unity if there is no instance of that script in the game yet?
<p>I need a way to add a script to an object that I just Instantiated. Ideally I could just set the script to add in the inspector. The problem is that I can't use </p>

<pre><code>public Component scriptToAdd; 
</code></pre>

<p>because then I would need to already have an empty object or something with the script on it. While that would work it feels kind of dirty or hackish to make an empty that just stores references to something. Also the point of doing it like this for me is to make it more efficient to swap out different scripts. If I had to swap out a script on an empty and then drag the new one in I'd lose on some of that efficiency I'm after. Thanks for any help.</p>