7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unityのエディタ拡張でコルーチン処理をする

7
Posted at

StartCoroutineが使えなくても大丈夫。

using UnityEngine;
using System.Collections;
using UnityEditor;

public class TestEditor : EditorWindow {

	[MenuItem("Test/Go")]
	static void Go() {
		GetWindow<TestEditor> ();
	}

	void OnGUI() {
		EditorGUILayout.LabelField ("Test");
		if (GUILayout.Button ("Push")) {
			Debug.Log ("Pushed");
			IEnumerator t = Test ();
			while (t.MoveNext ()) {
				Debug.Log ("Current: " + t.Current);
			}
		}
	}

	public IEnumerator Test() {
		Debug.Log ("Test 0");
		yield return "Test 1";
		Debug.Log ("Test 2");
		yield return "Test 3";
		Debug.Log ("Test 4");
	}
}
7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?