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); //큐브 포지션 설정
'Unity' 카테고리의 다른 글
(Unity) Mathf.Clamp를 이용하여 회전 범위 설정하기 (0) | 2023.01.02 |
---|---|
(Unity) 유니티 Scripts 라이프 사이클(생명주기,Life Cycle) (0) | 2022.12.16 |
(Unity) BoxCollider 코드로 켜고 끄기 (0) | 2022.12.06 |
(Unity) JSON을 통한 데이터 처리 in Unity (0) | 2022.10.24 |
(Unity) 코루틴, Couroutine (0) | 2022.10.12 |