Hi guys,
i’ve got a problem, i tried to search an answer in internet but i didn’t find it.
I’ve got this situation in my project:
public class GameController : MonoBehaviour {
public GameObject enemyShip;
public Object scriptToAdd; //custom script draggable in unity inspector
void Start()
{
enemyShip.AddComponent<scriptToAdd>(); //How to do this?
}
}
Following different topics i found solutions like enemyShip.AddComponent(scriptToAdd.GetType()) but didn’t works ad this message was shown in console: “Can’t add component because ‘MonoScript’ is not derived from Component.”
Can you help me please? i’m a very beginner in Unity, sorry. I’m asking for help because i haven’t found nothing that can help me.
Thanks in advance