Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Can I assign a script in the Inspector?

$
0
0
I want a script to AddComponent<SomeMonoBehaviour>() to it's gameObject, but I want to be able to assign different MonoBehaviours to add to the gameObject.

Example: I have a HealEverySecond MonoBehaviour and a DamageEverySecond MonoBehaviour. I want a third script to add one or the other, depending on what's assigned in the inspector. I can do this currently if I use a string, but then anything can be entered in the string field by anyone.
Code (csharp):
  1. // Is there anyway to assign the script directly?...
Can I assign a script in the Inspector?

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>