ํฌ์ŠคํŠธ

Code Block - Step

Code Block - Step

๐Ÿ’ซ Step


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public enum SomeStep
{
	None = 0,
	Step1 = 1,
	Step2 = 2,
	Step3 = 3,
	Step4 = 4,
	Step5 = 5,
}

public class SomeClass : MonoBehaviour
{
	private SomeStep step = SomeStep.None;

	public void SetStep(SomeStep newStep)
	{
		step = newStep;
	}

	private IEnumerator WaitForStep(SomeStep targetStep)
	{
		do yield return null;
		while (step != targetStep);
	}

	public void SomeMethod()
	{
		while (true)
		{
			// Do something
			Debug.Log("Doing something...");

			// Wait for step 3
			yield return StartCoroutine(WaitForStep(SomeStep.Step3));

			// Do something else
			Debug.Log("Doing something else...");

			// Wait for step 5
			yield return StartCoroutine(WaitForStep(SomeStep.Step5));
		}
	}
}
์ด ๊ธฐ์‚ฌ๋Š” ์ €์ž‘๊ถŒ์ž์˜ CC BY 4.0 ๋ผ์ด์„ผ์Šค๋ฅผ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.