How to create a GameObject in Unity? -- Unity
How to create a GameObject in Unity? -- Unity
In general, you can create a GamObject with a few steps.
Step1:
Empty GameObject
Step2:
Add a Compoenent you nedd.
How to create Empty GameObject:
using new GameObject.
e.g.
MyGO=new GameObject();
How to AddComponent:
using AddCompoenent method of the GameObject.
[syntax]
(1)AddComponent<typename>();
(2)AddComponent(typeof(typename));
(3)AddComponent("<typename>"); //obsolete
where typename is a name of component that your need.
e.g.
MyGO.AddComponent<Mesh>();
[NOTE]
(1)AddComponent("<typename>"); //it is obsolete, I recommend that don't use it.
more details on:
But I don't find the way that creating 3D Object with AddComponent method.
I find the new way.
How to create 3D Object?
using CreatePrimitive.
[syntax]
GameObject.CreatePrimitive(<typename>);
where typename is a name of component that your need.
e.g.
source:
Comments
Post a Comment