본문 바로가기
  • Being.Doing
  • Being.Doing
  • Being.Doing
Unity

Unity If Statement 조건

by MQ_CHOI 2021. 5. 20.

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가 더큽니다");
        }
    }



}

}

아래 처럼 입력이 가능하다

댓글


loading