C# 기반의 유니티의 조건문에는
크게
- if
- switch
- 삼항 연산자(ternary operator) 가 있다
if 부터 살펴보자면
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestIf : MonoBehaviour //TestIf 라는 클래스를 선언해준뒤
{
int a = 8; //integer Type의 a는 8
int b = 10; //b는 10이라는 변수를 선언해준뒤
bool result;
void start()
{
result = a > b
if(result) // result가 참일경우에 아래 구현부를 출력한다.
{
print("a가 더큽니다");
}
else
{
print("b가 더큽니다");
}
}
}
}
아래 처럼 입력이 가능하다
'Unity' 카테고리의 다른 글
[Unity 꿀팁] 26가지 에셋을 단돈 30달러에 만날수 있습니다. 14일 남았습니다. (2) | 2022.09.07 |
---|---|
[Unity 꿀팁] 에셋 스토어 잘 못 구입한 에셋 환불하는 방법 (1) | 2022.08.18 |
Unity 안에서 동영상 찍기(포트폴리오 작성시 매우 유용!) (0) | 2021.05.11 |
댓글