---
title: "IF 문"
content_type: tutorial
url: "https://learn.unity.com/tutorial/if-mun-v3?language=ko"
language: ko
difficulty: beginner
duration_minutes: 5
unity_version:
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
  - "2018.2"
  - "2018.1"
  - "2017.4"
  - "2017.3"
  - "2017.2"
  - "2017.1"
  - "5.x"
  - "4.x"
supported_unity_versions:
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko&version=4.x"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/if-statements.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/if-statements-1.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/if-sutetomento.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/if-mun-v3.md?language=ko"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/if-yu-ju.md?language=zh-cn"
last_updated: "2026-08-04T14:23:18.000Z"
---

# IF 문

C# 의 IF 문을 사용해 조건에 따라 코드 실행 흐름을 제어하는 방법을 배웁니다.

코드에 IF 문을 사용하여 조건을 설정하는 방법을 알아봅니다.

이 튜토리얼은 [스크립팅의 기초 프로젝트](https://learn.unity.com/project/beginner-gameplay-scripting)에 포함되어 있습니다.

이전: [규칙 및 구문](https://learn.unity.com/tutorial/conventions-and-syntax?projectId=5c8920b4edbc2a113b6bc26a)

다음: [루프](https://learn.unity.com/tutorial/loops-z2b?projectId=5c8920b4edbc2a113b6bc26a)

## 1. IF 문

[Video](https://connect-mediagw.unity.com/h1/20220104/videos/36d17490-e85a-4c44-b578-b8227de109e0_U_Beginner_4_IFstatements.mp4) ([Transcript (ko_kr)](https://connect-mediagw.unity.com/h1/20220427/222e6a52-0d2f-4593-95fb-781e1ecd8627_04_If_statements.ko.vtt))

```csharp
using UnityEngine;
using System.Collections;

public class IfStatements : MonoBehaviour
{
    float coffeeTemperature = 85.0f;
    float hotLimitTemperature = 70.0f;
    float coldLimitTemperature = 40.0f;
    

    void Update ()
    {
        if(Input.GetKeyDown(KeyCode.Space))
            TemperatureTest();
        
        coffeeTemperature -= Time.deltaTime * 5f;
    }
    
    
    void TemperatureTest ()
    {
        // 커피 온도가 가장 뜨거운 섭취 온도보다 높은 경우
        if(coffeeTemperature > hotLimitTemperature)
        {
            // 다음을 실행합니다.
            print("Coffee is too hot.");
        }
        // 그렇지 않고 커피 온도가 가장 차가운 섭취 온도보다 낮은 경우
        else if(coffeeTemperature < coldLimitTemperature)
        {
            // 다음을 실행합니다.
            print("Coffee is too cold.");
        }
        // 둘 다 해당하지 않는 경우
        else
        {
            // 다음을 실행합니다.
            print("Coffee is just right.");
        }
    }
}
```
