Class EditorWindowCoroutineExtension | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class EditorWindowCoroutineExtension

    Inheritance
    System.Object
    EditorWindowCoroutineExtension
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Unity.EditorCoroutines.Editor
    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
    System.Collections.IEnumerator routine
    Returns
    Type Description
    EditorCoroutine

    StopCoroutine(EditorWindow, EditorCoroutine)

    Immediately stop an EditorCoroutine that was started by the calling 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
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023