- Home /
A curious case of "new" keyword LogWarning when creating monobehaviours.
Hi,
Im wondering about something I am doing that is causing this well known warning:
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all.
I am well aware that the solution to this would be to simply use AddComponent< T>, However in my case the place I am getting this error is when running my [test] functions. And what I am creating is:
GameObject actor;
actor = new GameObject();
Im wondering if there is any other way that I could possibly create gameObjects without incurring this logwarning?
Your answer
Follow this Question
Related Questions
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. 2 Answers
Can someone tell me whats the difference between these? 1 Answer
How do you get console messages in order? 0 Answers
Newbie: How do I test/run the Roll-a-Ball iPhone sample from the Asset store? 1 Answer