Quantcast
Channel: Questions in topic: "log"
Viewing all articles
Browse latest Browse all 235

A curious case of "new" keyword LogWarning when creating monobehaviours.

$
0
0
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?

Viewing all articles
Browse latest Browse all 235

Trending Articles



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