Class EditorWindowCoroutineExtension
Extension class for allowing EditorWindow derived types to access coroutine functionality.
Inherited Members
Namespace: Unity.EditorCoroutines.Editor
Assembly: Unity.EditorCoroutines.Editor.dll
Syntax
public static class EditorWindowCoroutineExtension
Methods
StartCoroutine(EditorWindow, IEnumerator)
Start an EditorCoroutine, owned by the calling EditorWindow instance.
using System.Collections;
using Unity.EditorCoroutines.Editor;
using UnityEditor;
public class ExampleWindow : EditorWindow
{
void OnEnable()
{
this.StartCoroutine(CloseWindowDelayed());
}
IEnumerator CloseWindowDelayed() //close the window after 1000 frames have elapsed
{
int count = 1000;
while (count > 0)
{
yield return null;
}
Close();
}
}
Declaration
public static EditorCoroutine StartCoroutine(this EditorWindow window, IEnumerator routine)
Parameters
| Type | Name | Description |
|---|---|---|
| EditorWindow | window | The EditorWindow instance that owns the coroutine. |
| IEnumerator | routine | The IEnumerator to execute as a coroutine. |
Returns
| Type | Description |
|---|---|
| EditorCoroutine | A handle to the started EditorCoroutine. |
StopCoroutine(EditorWindow, EditorCoroutine)
Immediately stop an EditorCoroutine that was started by the calling EditorWindow instance. This method is safe to call on an already completed EditorCoroutine.
using System.Collections;
using Unity.EditorCoroutines.Editor;
using UnityEditor;
using UnityEngine;
public class ExampleWindow : EditorWindow
{
EditorCoroutine coroutine;
void OnEnable()
private void OnDisable()
{
this.StopCoroutine(coroutine);
}
IEnumerator CloseWindowDelayed()
{
while (true)
{
Debug.Log("Running");
yield return null;
}
}
}
Declaration
public static void StopCoroutine(this EditorWindow window, EditorCoroutine coroutine)
Parameters
| Type | Name | Description |
|---|---|---|
| EditorWindow | window | The EditorWindow instance that owns the coroutine. |
| EditorCoroutine | coroutine | The EditorCoroutine to stop. |