jacksondunstan / UnityNativeScripting

Unity Scripting in C++

Home Page:https://jacksondunstan.com/articles/3938

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to new GameObject(constructor not correct)

sekkit opened this issue · comments

new GameObject()
But no gameobject is created in scene.
Based on Blog articles, there is a GameObjectNew func can do that?
so the question is, how to create GameObject(or any other Plugin generated object) correctly?

You'll need to expose that constructor to C++ in order to use it. Here's how the JSON looks:

{
	"Name": "UnityEngine.GameObject",
	"Constructors": [
		{
			"ParamTypes": []
		}
	]
}

After generating the bindings, you can create the GameObject in C++ like so:

GameObject go;

Can't I just GameObject *go = new GameObject()?
why create it in stack? I noticed there is no pointer in your cpp plugin bindings