Expose scripting variable?

Hey Unityers, quick question here.

Yall know how you can expose a variable in the inspect by declaring as a global (ex: var number = 10) making it easy to change quickly, but more importantly, able to have things like prefabs or in-scene objects assigned to it.

Just out of curiousity, is it possible to declare a generic script variable that can be assigned onto an object in the editor? Like, for example, if I declare (javascript) var object : GameObject I can assign a prefab onto the variable from my prefabs folder. Could I do something like var anyScript : Script and assign any script from my scripting folder?

If you’re wondering why I want to do this, it’s mostly so I can make a bunch of “ability” scripts that would fit into the Script[ ] slots of an AbilityHolder style script…each “ability” script would have essentially the same variables (cooldown, power cost, duration…think RPGish) and I think this would be a convienient way to keep it neat and tidy.

And yes, I am aware that I can just do var script; (javascript) and then go script = GetComponent(MyScript) if I want to. And yes, I am aware that I can just create an array of Strings as an exposed global variable and use that to access the scripts, but I want something easier and simpler. And knowing a bit more about unity can’t hurt…

Thanks for any answers!

Create an Ability class that each ability extends and you’ll find you’ll experience far fewer bug/headache issues. Then you’d have a var ability : Ability that could take any Ability.

Ahh that would make it a ton easier, great idea! Thanks for the help!