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.
Can I assign a script in the Inspector?
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):
- // Is there anyway to assign the script directly?...