- Home /
Question by
Tatanan · Sep 09, 2014 at 09:53 AM ·
c#gameobjectmonobehaviour
Creating GameObjects and MonoBehaviours
I want to use coroutines with an object created on the fly. I make:
GameObject _instance = new GameObject("My Timer");
MonoBehaviour _mono = _instance.AddComponent<MonoBehaviour> ();
inside MyClass. Is is correct? If so, why on the inspector (when pressing PLAY), I read "The associated script can not be loaded. Please fix any compile errors and assign valid script"?
Comment
Answer by Graham-Dunnett · Sep 09, 2014 at 09:54 AM
You use the name of the script (or the class name) and not MonoBehaviour
.
Am I forced to create a new class extending $$anonymous$$onoBehaviour? I don't want any extra method, but just to use StartCoroutine.
Your answer
Follow this Question
Related Questions
How can I return a GameObject? 1 Answer
Multiple Cars not working 1 Answer
How to track all Update() calls to find infinite loop 2 Answers
Access the GameObject a class is attached to 1 Answer
Distribute terrain in zones 3 Answers