A-Dyu의 개발 일기장
[유니티]기본 Shape 생성 본문
유니티에서 기본적으로 제공하는 shape은 Cube, Sphere, Capsule등 여러가지 있다.
이런 도형들을 런타임 시점 때 생성할 수 없을까?
정답은 GameObject.CreatePrimitive 메서드를 사용하면 된다.
using UnityEngine;
public class Test : MonoBehaviour
{
void Update()
{
//Sphere 생성
GameObject.CreatePrimitive(PrimitiveType.Sphere);
//Cube 생성
GameObject.CreatePrimitive(PrimitiveType.Cube);
//Capsule 생성
GameObject.CreatePrimitive(PrimitiveType.Capsule);
}
}
인자로 들어가는 PrimitiveType의 종류는 다음과 같다.
Sphere | Sphere의 원형 |
Capsule | Capsule의 원형 |
Cylinder | Cylinder의 원형 |
Cube | Cube의 원형 |
Plane | Plane의 원형 |
Quad | Quad의 원형 |
설명이 필요하지 않을 것 같지만;;일단 설명을 적어두었다.
'유니티 > 유니티 기능' 카테고리의 다른 글
[유니티]RequireComponent 어트리뷰트 (0) | 2024.05.22 |
---|---|
[유니티]CreateAssetMenu 어트리뷰트 (0) | 2024.05.22 |
[유니티] ContextMenu 어트리뷰트 (0) | 2024.05.21 |
[유니티]유니티 기본 폰트 가져오기 (0) | 2024.05.21 |
[유니티] 마우스 포인터가 UI위에 올려져 있는지 (0) | 2024.05.21 |