docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class EditorWindowCoroutineExtension

    Inheritance
    object
    EditorWindowCoroutineExtension
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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
    IEnumerator routine
    Returns
    Type Description
    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()
        {
            coroutine = this.StartCoroutine(CloseWindowDelayed());
        }
    
        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
    EditorCoroutine coroutine
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)