---
title: "루프"
content_type: tutorial
url: "https://learn.unity.com/tutorial/rupeu-eap?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/rupeu-eap.md?language=ko&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko&version=4.x"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/loops-z2b.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/bucles-xu.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/rupuwen-b.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/rupeu-eap.md?language=ko"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/xun-huan.md?language=zh-cn"
last_updated: "2026-08-04T14:21:23.000Z"
---

# 루프

Learn to repeat actions in code using For, While, Do-While, and For Each loops as part of your scripting fundamentals.

코드에 For, While, Do-While, For Each 루프를 사용하여 액션을 반복하는 방법을 알아봅니다.

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

이전: [If 문](https://learn.unity.com/tutorial/if-statements?projectId=5c8920b4edbc2a113b6bc26a)

다음: [범위 및 액세스 한정자](https://learn.unity.com/tutorial/scope-and-access-modifiers?projectId=5c8920b4edbc2a113b6bc26a)

## 1. 루프

[Video](https://connect-mediagw.unity.com/h1/20220104/videos/baa7cab6-13a9-4355-8b6d-a6c0f8c9b3dd_U_Beginner_5_Loops.mp4) ([Transcript (ko_kr)](https://connect-mediagw.unity.com/h1/20220427/71d68675-e1a2-4c22-99d8-2f70da729133_05_Loops.ko.vtt))

## **For 루프**

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

public class ForLoop : MonoBehaviour
{
    int numEnemies = 3;
    
    
    void Start ()
    {
        for(int i = 0; i < numEnemies; i++)
        {
            Debug.Log("Creating enemy number: " + i);
        }
    }
}
```

## **While 루프**

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

public class WhileLoop : MonoBehaviour
{
    int cupsInTheSink = 4;
    
    
    void Start ()
    {
        while(cupsInTheSink > 0)
        {
            Debug.Log ("I've washed a cup!");
            cupsInTheSink--;
        }
    }
}
```

## **DoWhile 루프**

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

public class DoWhileLoop : MonoBehaviour 
{
    void Start()
    {
        bool shouldContinue = false;
        
        do
        {
            print ("Hello World");
            
        }while(shouldContinue == true);
    }
}
```

## **Foreach 루프**

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

public class ForeachLoop : MonoBehaviour 
{   
    void Start () 
    {
        string[] strings = new string[3];
        
        strings[0] = "First string";
        strings[1] = "Second string";
        strings[2] = "Third string";
        
        foreach(string item in strings)
        {
            print (item);
        }
    }
}
```
