Unity

(Unity) Script로 오브젝트 생성하기 - CreatePrimitive

Janny_ 2022. 12. 7. 23:08

https://docs.unity3d.com/ScriptReference/GameObject.CreatePrimitive.html

 

Unity - Scripting API: GameObject.CreatePrimitive

Note: CreatePrimitive may fail at runtime. This will happen if your project does not reference the following components: MeshFilter, MeshRenderer, and BoxCollider or SphereCollider at runtime. The recommended way to avoid this crash is to declare private p

docs.unity3d.com

 

Sphere, Cylinder, Cube, Capsule, Plane 등 생성 가능

 

GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);    //큐브 오브젝트 생성

cube.transform.position = new Vector3(0, 0, 0);                                 //큐브 포지션 설정