728x90 유니티 반복문2 C#기초 - 반복문 while 사용법 while 문은 괄호 안에 조건이 만족하는 동안 중괄호 안에 있는 코드가 반복적으로 실행된다. while 문의 기본 구조는 아래와 같다. while (true){} 다만 이렇게 괄호 안에 true를 넣은 상태로 플레이해버리면 { } 안의 코드가 무한반복된다. (유니티가 중단될 수도 있으니 주의) 반복예시를 아래와 같이 쓰면 using System.Collections;using System.Collections.Generic;using UnityEditor;using UnityEngine;public class Study4_Loop : MonoBehaviour{ void Start() { int count = 0; //count 값 선언 .. 2024. 4. 20. C#기초 - 반복문 for문 사용법 for문은 반복 횟수를 지정하면 자동으로 반복 횟수만큼 처리한다.for문의 형식은 다음과 같다. using System.Collections;using System.Collections.Generic;using UnityEngine;public class test : MonoBehaviour{ // Start is called before the first frame update void Start() { for (변수 초기화; 반복 조건식; 변수 갱신) { 처리 } } // Update is called once per frame void Update() { .. 2023. 4. 28. 이전 1 다음 728x90