{"id":128,"date":"2018-06-30T17:54:21","date_gmt":"2018-06-30T08:54:21","guid":{"rendered":"http:\/\/batmask.dothome.co.kr\/?p=128"},"modified":"2025-09-09T09:19:06","modified_gmt":"2025-09-09T00:19:06","slug":"unity-%ec%9d%98-coroutine%ec%97%90-%eb%8c%80%ed%95%b4-%ec%95%8c%ec%95%84%eb%b3%b4%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/batmask.net\/index.php\/2018\/06\/30\/128\/","title":{"rendered":"Unity \uc758 Coroutine\uc5d0 \ub300\ud574 \uc54c\uc544\ubcf4\uae30"},"content":{"rendered":"\n<p>\uc720\ub2c8\ud2f0\ub97c \uacf5\ubd80\ud558\ub358 \uc911, \uc54c\uc544\uc57c \ud558\uc9c0\ub9cc \uc774\ud574\ud558\uae30 \uc5b4\ub824\uc6b4 \uac1c\ub150\uc744 \uc811\ud588\ub2e4. \ubc14\ub85c Coroutine. \uc77c\ubc18\uc801\uc778 \uc0ac\uc6a9\uc740 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>using UnityEngine;\nusing System.Collections;\n\npublic class CoroutinesExample : MonoBehaviour\n{\n    public float smoothing = 1f;\n    public Transform target;\n    \n    \n    void Start ()\n    {\n        StartCoroutine(MyCoroutine(target));\n    }\n    \n    \n    IEnumerator MyCoroutine (Transform target)\n    {\n        while(Vector3.Distance(transform.position, target.position) > 0.05f)\n        {\n            transform.position = Vector3.Lerp(transform.position, target.position, smoothing * Time.deltaTime);\n            \n            yield return null;\n        }\n        \n        print(\"Reached the target.\");\n        \n        yield return new WaitForSeconds(3f);\n        \n        print(\"MyCoroutine is now finished.\");\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F47067\">using<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">UnityEngine<\/span><span style=\"color: #ADBAC7\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F47067\">using<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">System<\/span><span style=\"color: #ADBAC7\">.<\/span><span style=\"color: #F69D50\">Collections<\/span><span style=\"color: #ADBAC7\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F47067\">public<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">class<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">CoroutinesExample<\/span><span style=\"color: #ADBAC7\"> : <\/span><span style=\"color: #F69D50\">MonoBehaviour<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">public<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">float<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">smoothing<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">1f<\/span><span style=\"color: #ADBAC7\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">public<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">Transform<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">target<\/span><span style=\"color: #ADBAC7\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">void<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #DCBDFB\">Start<\/span><span style=\"color: #ADBAC7\"> ()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><span style=\"color: #DCBDFB\">StartCoroutine<\/span><span style=\"color: #ADBAC7\">(<\/span><span style=\"color: #DCBDFB\">MyCoroutine<\/span><span style=\"color: #ADBAC7\">(target));<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F69D50\">IEnumerator<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #DCBDFB\">MyCoroutine<\/span><span style=\"color: #ADBAC7\"> (<\/span><span style=\"color: #F69D50\">Transform<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">target<\/span><span style=\"color: #ADBAC7\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><span style=\"color: #F47067\">while<\/span><span style=\"color: #ADBAC7\">(Vector3.<\/span><span style=\"color: #DCBDFB\">Distance<\/span><span style=\"color: #ADBAC7\">(transform.position, target.position) <\/span><span style=\"color: #F47067\">&gt;<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">0.05f<\/span><span style=\"color: #ADBAC7\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">            transform.position <\/span><span style=\"color: #F47067\">=<\/span><span style=\"color: #ADBAC7\"> Vector3.<\/span><span style=\"color: #DCBDFB\">Lerp<\/span><span style=\"color: #ADBAC7\">(transform.position, target.position, smoothing <\/span><span style=\"color: #F47067\">*<\/span><span style=\"color: #ADBAC7\"> Time.deltaTime);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">            <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">            <\/span><span style=\"color: #F47067\">yield<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">return<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">null<\/span><span style=\"color: #ADBAC7\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><span style=\"color: #DCBDFB\">print<\/span><span style=\"color: #ADBAC7\">(<\/span><span style=\"color: #96D0FF\">&quot;Reached the target.&quot;<\/span><span style=\"color: #ADBAC7\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><span style=\"color: #F47067\">yield<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">return<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">new<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">WaitForSeconds<\/span><span style=\"color: #ADBAC7\">(<\/span><span style=\"color: #6CB6FF\">3f<\/span><span style=\"color: #ADBAC7\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><span style=\"color: #DCBDFB\">print<\/span><span style=\"color: #ADBAC7\">(<\/span><span style=\"color: #96D0FF\">&quot;MyCoroutine is now finished.&quot;<\/span><span style=\"color: #ADBAC7\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\uc704 \ucf54\ub4dc\ub294 \uc720\ub2c8\ud2f0 \uacf5\uc2dd \uc0ac\uc774\ud2b8\uc5d0\uc11c <a href=\"https:\/\/unity3d.com\/kr\/learn\/tutorials\/topics\/scripting\/coroutines\">Script \uc124\uba85\uc911 Coroutine\uc5d0 \ub300\ud55c \uc124\uba85<\/a>\uc5d0\uc11c \ub530\uc628 \uac83\uc774\ub2e4. <span style=\"color: #003366;\"><span style=\"color: #993300;\">StartCoroutine<\/span> <\/span>\ud638\ucd9c\uc774 \ubcf4\uc774\uace0, MyCoroutine\uc740<span style=\"color: #993300;\"> IEnumerator <\/span>\ubc18\ud658\uac12\uc744 \uac16\ub294\ub2e4. \ud568\uc218\uc548\uc5d0\ub294 <span style=\"color: #993300;\">yield <\/span>return null;,&nbsp;&nbsp;<span style=\"color: #003366;\"><span style=\"color: #993300;\">yield<\/span> <\/span>return new WaitForSeconds(3f) \uc640\uac19\uc774 \uc0ac\uc6a9\ud55c\ub2e4. \uccab \uac10\uc0c1\uc740 &#8220;\uc774\uac8c \ub2e4 \ub300\uccb4 \ubb50\uc57c?&#8221;<\/p>\n\n\n\n<p>\uc77c\ub2e8, \ud0a4\uc6cc\ub4dc\ub4e4\uc744 \ucd94\ucd9c\ud574 \ubd24\ub2e4.<span style=\"color: #993300;\"> StartCoroutine, IEnumerator, yield.&nbsp;<span style=\"color: #000000;\">\ud638\ucd9c\ud558\ub294 \ud615\ud0dc\ub098, yield \ud0a4\uc6cc\ub4dc\ub4f1\uc744 \ubd10\uc11c\ub294 \uc4f0\ub808\ub4dc\uc778\uac00 \uc0dd\uac01\uc774 \ub4e4\uaca0\uc9c0\ub9cc, \uc77c\ub2e8 \uc4f0\ub808\ub4dc\ub294 \uc544\ub2c8\ub77c\uace0 \ud55c\ub2e4. \ubb38\uc81c \uc18c\uc9c0\uac00 \ub9ce\uc740 \uba40\ud2f0 \uc4f0\ub808\ub4dc\ub97c \uc4f0\uc9c0 \uc54a\uace0, \uac8c\uc784 \uc5d4\uc9c4 \uc790\uccb4\uc5d0\uc11c \ucf5c\ubc31 \ud615\uc2dd\uc73c\ub85c \uc720\uc0ac\ud558\uac8c \uad6c\ud604\ud574 \ub193\uc740 \uac83 \uac19\ub2e4. \uc81c\ub300\ub85c \uc774\ud574\ud558\uae30 \uc704\ud574\uc120, IEnumerator\ubd80\ud130 \ud558\ub098\uc529 \ud30c\ubcfc \ud544\uc694\uac00 \uc788\ub2e4.&nbsp;<\/span><\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>IEnumerator<\/strong><\/h2>\n\n\n\n<p><a href=\"http:\/\/theeye.pe.kr\/archives\/2725\">&nbsp;IEnumerator\ubd80\ud130 \uc815\ub9d0 \ucd5c\uace0\uc758 \uc124\uba85\uc744 \ud574\ub193\uc740 \ube14\ub85c\uadf8<\/a>\uac00 \uc788\ub2e4.&nbsp; \uc77c\ub2e8, IEnumerator\ub97c \ucc3e\uc544\ubcf4\uba74, <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.collections.ienumerator(v=vs.110).aspx\">C# \ub2e4\ud050\uba3c\ud2b8\ucabd\uc5d0\uc11c \uc774 \uc778\ud130\ud398\uc774\uc2a4\uc5d0 \uad00\ud55c \uc124\uba85<\/a>\uc744 \ucc3e\uc744 \uc218 \uc788\ub2e4. \uc124\uba85\uc744 \ubcf4\uba74, \uadf8\ub0e5 \ub098\uc5f4\uc790(Enumerator) \uc778\ud130\ud398\uc774\uc2a4\uc774\ub2e4. Collection\uc5d0\uc11c \ud604\uc7ac Element\ub97c \ub3cc\ub824\uc8fc\ub294 Current \uc18d\uc131\uacfc \ub2e4\uc74c Element\ub85c \ud558\ub098 \uc804\uc9c4\ud0a4\uc2dc\ub294 MoveNext(), \ucc98\uc74c \uc704\uce58\ub85c \ucd08\uae30\ud654 \uc2dc\ud0a4\ub294 Reset() \uba54\uc18c\ub4dc\ub97c \uac16\uace0 \uc788\ub2e4. \uc77c\uc885\uc758 \uc774\ud130\ub808\uc774\ud130\ucc98\ub7fc \uc0ac\uc6a9\ud558\ub294 \uac83\uc73c\ub85c \ubcc4 \uc0dd\uac01\uc5c6\uc774 \uc0ac\uc6a9\ud558\ub358 foreach\ubb38\uc774 \uc774\ub97c \uc774\uc6a9\ud558\ub294 \uac83 \uac19\ub2e4.<\/p>\n\n\n\n<p>\ub9ac\ud134\uac12\uc774 IEnumerator \uc778\ub370, \ubc18\ud658\uac12\ub4e4\uc774 \uc774 \uc778\ud130\ud398\uc774\uc2a4\ub97c \uad6c\ud604\ud558\uace0 \uc788\ub098? \ub77c\ub294 \uc758\ubb38\uc774 \ub4e4\uac70\ub2e4. \uc790\uc138\ud55c\uac74 yield\uc5d0 \ub300\ud574 \uc54c\uc544\ubcf4\uace0 \uc598\uae30\ud558\uc790.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>yield<\/strong><\/h2>\n\n\n\n<p>\uc4f0\ub808\ub4dc\ub77c\uba74, \uc6b0\uc120\uc21c\uc704\ub97c \uc591\ubcf4\ud558\ub294 \uc758\ubbf8\uc758 yield. \uc774\uac83\ub3c4 \uc77c\ub2e8, <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/keywords\/yield\">C#\ub808\ud37c\ub7f0\uc2a4<\/a>\ub97c \uc0b4\ud3b4\ubcf4\uc790.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-style-default is-layout-flow wp-block-quote-is-layout-flow\">\n<p>The return type must be\u00a0<a class=\"xref\" data-linktype=\"absolute-path\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.collections.ienumerable\">IEnumerable<\/a>,\u00a0<a class=\"xref\" data-linktype=\"absolute-path\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.collections.generic.ienumerable-1\">IEnumerable&lt;T><\/a>,\u00a0<a class=\"xref\" data-linktype=\"absolute-path\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.collections.ienumerator\">IEnumerator<\/a>, or\u00a0<a class=\"xref\" data-linktype=\"absolute-path\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.collections.generic.ienumerator-1\">IEnumerator&lt;T><\/a>.<\/p>\n\n\n\n<p>&#8230;<\/p>\n\n\n\n<p>You use a\u00a0<code>yield return<\/code>\u00a0statement to return each element one at a time.<\/p>\n\n\n\n<p>You consume an iterator method by using a\u00a0<a data-linktype=\"relative-path\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/keywords\/foreach-in\">foreach<\/a>\u00a0statement or LINQ query. Each iteration of the\u00a0<code>foreach<\/code>\u00a0loop calls the iterator method. When a\u00a0<code>yield return<\/code>\u00a0statement is reached in the iterator method,\u00a0<code>expression<\/code>\u00a0is returned, and the current location in code is retained. Execution is restarted from that location the next time that the iterator function is called.<\/p>\n\n\n\n<p>You can use a\u00a0<code>yield break<\/code>\u00a0statement to end the iteration.<\/p>\n<\/blockquote>\n\n\n\n<p>\uc124\uba85\uc744 \uc77d\uc5b4\ubcf4\uba74, IEnumerable&lt;T&gt;, IEnumerator \ub9ac\ud134\ud0c0\uc785\uc73c\ub85c \uc815\uc758\ud55c \uba54\uc18c\ub4dc\ub294 iterator \uba54\uc18c\ub4dc\uac00 \ub41c\ub2e4\uace0 \ud55c\ub2e4.&nbsp; iterator \uba54\uc18c\ub4dc\uac00 \ud638\ucd9c\ub420 \ub54c,&nbsp; yield return &lt;expression&gt; \uc744 \ub9cc\ub098\uba74 &lt;expression&gt;\uc744 \ub9ac\ud134\ud558\uace0, \uadf8 \uc704\uce58\uac00 \uc800\uc7a5\ub41c\ub2e4\uace0 \ud55c\ub2e4. \uadf8\ub9ac\uace0 \ub2e4\uc74c \ud638\ucd9c \uc2dc, \uc800\uc7a5\ub41c \uc704\uce58\ubd80\ud130 \uc2dc\uc791\ub41c\ub2e4\ub294 \uc598\uae30. \ub9cc\uc57d, yield break;\ub97c \uc0ac\uc6a9\ud558\uba74 \uc774\ud130\ub808\uc774\uc158\uc774 \ub05d\ub09c\ub2e4\uace0\ud55c\ub2e4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>MyCoroutine\uc758 \uc774\ud574<\/strong><\/h2>\n\n\n\n<p>\uba87\uac00\uc9c0 \uc5b8\uc5b4\ub4e4\uc744 \uc0ac\uc6a9\ud574 \uc654\uc9c0\ub9cc, \ucc98\uc74c \uc811\ud558\ub294 \uac1c\ub150\uc774\ub2e4. \uadf8\ub798\ub3c4, IEnumerator\uc640 yield\ub97c \uc54c\uace0 \ub098\ub2c8, \ucc98\uc74c\uc5d0 \ubcf4\uc778 Unity \ucf54\ub4dc\uc5d0\uc11c&nbsp;MyCoroutine \uba54\uc18c\ub4dc\uc5d0 \ub300\ud574 \uc774\ud574\uac00 \ub41c\ub2e4.<\/p>\n\n\n\n<p>IEnumerator \ubd80\ubd84\uc5d0\uc11c \uac00\uc84c\ub358 \uc758\ubb38\uc744 \ud480\uc5b4\ubcf4\uc790. \uc55e\uc11c yield \ud56d\ubaa9\uc744 \uc77d\uc5b4\ubcf4\uba74, IEnumerator \ub9ac\ud134\uac12\uc73c\ub85c \uc815\uc758\ud55c \uba54\uc18c\ub4dc\ub294 iterator \uba54\uc18c\ub4dc\uac00 \ub41c\ub2e4. \uba54\uc18c\ub4dc \uc790\uccb4\uc5d0 IEnumerator \uc778\ud130\ud398\uc774\uc2a4\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4\ub294 \uc598\uae30\ub2e4. \ucc98\uc74c unity \ucf54\ub4dc\ub85c \ub3cc\uc544\uac00\uba74, MyCoroutine()\uc744 \uac00\uc9c0\uace0 \ub2e4\uc74c\ucc98\ub7fc \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4\ub294 \uc598\uae30\uac00 \ub41c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:c# decode:true\">IEnumerator enumerator = MyCoroutine(transform);\nSystem.Object object = enumerator.Current;\nenumerator.MoveNext();<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>StartCoroutine()\uc758 \uc774\ud574<\/strong><\/h2>\n\n\n\n<p>\uc774\uc81c StartCoroutine()\uc744 \uc774\ud574\ud574\ubcf4\uc790. \uc55e\uc120 \ub0b4\uc6a9\uc73c\ub85c \ucd94\uce21\uc774 \uac00\ub2a5\ud558\ub2e4. iterator \uba54\uc18c\ub4dc\uc778 MyCoroutine()\uc744 \ub9ac\ud134\uac12\uc774 false\uc77c \ub54c\uae4c\uc9c0 \ubc18\ubcf5\uc801\uc73c\ub85c \ud638\ucd9c\ud558\uba70, MyCoroutine()\uc740 \ucc28\ub840\ub300\ub85c \uac1d\uccb4\ub97c \ub9ac\ud134\ud574\uc8fc\uac8c \ub41c\ub2e4. StartCoroutine()\uc740 IEnumerator.Currnt\ub85c \ud604\uc7ac \ub9ac\ud134\ub41c \uac1d\uccb4\ub97c \uc5bb\uc5b4\uc640 \uc5b4\ub5a4 \uac1d\uccb4\uc778\uc9c0\uc5d0 \ub530\ub77c \uc801\uc808\ud55c \ucc98\ub9ac\ub97c \ud574\uc8fc\uac8c \ub41c\ub2e4. \uad00\ub828 \ub0b4\uc6a9\uc740 <a href=\"http:\/\/theeye.pe.kr\/archives\/2725\">\uc55e\uc11c \uc5b8\uae09\ud55c \ube14\ub85c\uadf8<\/a>\uc5d0 \uc798 \ub098\uc640\uc788\ub2e4. \uadf8\ub807\ub2e4\uba74, \ub9ac\ud134\ubc1b\uc544 \ucc98\ub9ac\ud558\ub294 \uac1d\uccb4\uac00 \ud55c\uc815\ub418\uc5b4 \uc788\ub2e4\ub294 \ucd94\uce21\uc774 \uac00\ub2a5\ud558\ub2e4. \ubb38\uc11c\ub97c \ucc3e\uc544\ubcf4\uba74, <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/YieldInstruction.html\">YieldInstruction<\/a> \uc744 \uc0c1\uc18d\ud55c \uac1d\uccb4\ub4e4\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 \uac83 \uac19\ub2e4. WaitForEndFrame, WaitForFixedUpdate, WaitForSeconds, WaitForSecondsRealtime \ub4f1\uc774 \uc788\ub2e4.<\/p>\n\n\n\n<p>\uc8fc\uc6cc\ubaa8\uc740 \uc9c0\uc2dd\uc744 \uc885\ud569\ud574\uc11c \ucc98\uc74c\uc758 \uc720\ub2c8\ud2f0 \ucf54\ub4dc\ub85c \ub3cc\uc544\uac00\ubcf4\uba74, yield return null \uc774 \ubcf4\uc778\ub2e4. null \ub9ac\ud134\uc5d0 \ub300\ud574\uc120 \uc5b8\uae09\ud55c\uc801\uc774 \uc5c6\ub294\ub370, \ub2e4\uc74c Update()\ub97c \uae30\ub2e4\ub824\uc11c Update()\uac00 \uc2e4\ud589\ub41c \ud6c4, \uc774\uc5b4\uc11c \uc9c4\ud589\ub41c\ub2e4\uace0 \ud55c\ub2e4. while\ub8e8\ud504 \uc870\uac74\uc744 \ube60\uc838\ub098\uac14\uc744 \ub54c,&nbsp;yield return new WaitForSeconds(3f); \uac00 \ubd88\ub9ac\ub294\uac8c \ubcf4\uc778\ub2e4. 3\ucd08 \ud6c4\uc5d0 \ucf54\ub8e8\ud2f4\uc774 \ub2e4\uc2dc \ubd88\ub9b0\ub2e4\ub294 \uc598\uae30\uac00 \ub41c\ub2e4. \uc989, 3\ucd08\ud6c4\uc5d0&nbsp;&#8220;MyCoroutine is now finished.&#8221; \ubb38\uad6c\uac00 \ucc0d\ud788\uac8c \ub420 \uac83\uc774\ub2e4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\uadf8 \ub2e4\uc74c\uc740?<\/strong><\/h2>\n\n\n\n<p>\ub108\ubb34 \uc0c8\ub85c\uc6b4 \ub0b4\uc6a9\uc774\ub77c\uc11c \uac04\ub7b5\ud558\uac8c StartCoroutine() \uad00\ub828 \ub0b4\uc6a9\uc744 \uc0b4\ud3b4\ubd24\ub2e4. \uc2e4\uc81c \uac8c\uc784\uc81c\uc791 \ucf54\ub4dc\ub4e4\uc5d0\uc11c \uc774 \ub0b4\uc6a9\uc774 \uc774\ud574\ub97c \ub3d5\uae30\ub97c \ubc14\ub780\ub2e4. \ub098\ub3c4 \uacf5\ubd80\uc911\uc774\uc9c0\ub9cc, \uc544\ub9c8\ub3c4 \uac70\uc758 \ud544\uc218\uc801\uc73c\ub85c \uc0ac\uc6a9\ud558\ub294\uac8c \uc544\ub2d0\uae4c \uc0dd\uac01\uc774 \ub41c\ub2e4. \uadf8\ub7fc \uc774\ub9cc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc720\ub2c8\ud2f0\ub97c \uacf5\ubd80\ud558\ub358 \uc911, \uc54c\uc544\uc57c \ud558\uc9c0\ub9cc \uc774\ud574\ud558\uae30 \uc5b4\ub824\uc6b4 \uac1c\ub150\uc744 \uc811\ud588\ub2e4. \ubc14\ub85c Coroutine. \uc77c\ubc18\uc801\uc778 \uc0ac\uc6a9\uc740 \ub2e4\uc74c\uacfc \uac19\ub2e4. \uc704 \ucf54\ub4dc\ub294 \uc720\ub2c8\ud2f0 \uacf5\uc2dd \uc0ac\uc774\ud2b8\uc5d0\uc11c Script \uc124\uba85\uc911 Coroutine\uc5d0 \ub300\ud55c \uc124\uba85\uc5d0\uc11c \ub530\uc628 \uac83\uc774\ub2e4. StartCoroutine \ud638\ucd9c\uc774 \ubcf4\uc774\uace0, MyCoroutine\uc740 IEnumerator \ubc18\ud658\uac12\uc744 \uac16\ub294\ub2e4. \ud568\uc218\uc548\uc5d0\ub294 yield return null;,&nbsp;&nbsp;yield return new WaitForSeconds(3f) \uc640\uac19\uc774 \uc0ac\uc6a9\ud55c\ub2e4. \uccab \uac10\uc0c1\uc740 &#8220;\uc774\uac8c \ub2e4 \ub300\uccb4 \ubb50\uc57c?&#8221; \uc77c\ub2e8, \ud0a4\uc6cc\ub4dc\ub4e4\uc744 \ucd94\ucd9c\ud574 \ubd24\ub2e4. StartCoroutine, IEnumerator, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[109,25,26,21],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-unity","tag-c","tag-coroutine","tag-ienumerator","tag-unity"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":4,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":3424,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/128\/revisions\/3424"}],"wp:attachment":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}