docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Write a Unity Editor window test

    To test UI rendering and custom Unity Editor windows, write a test that captures the Unity Editor interface.

    For more information about using a test after you write it, refer to Run a graphics test for the first time and Run a test and check the results.

    Capture an Editor window

    To capture an Editor window as a texture, use the EditorWindowCapture.CaptureAsync API. Follow these steps:

    1. Create an EditorWindow object with the window you want to capture. For example:

      EditorWindow window = EditorWindow.CreateWindow<SceneView>();
      
    2. Create capture settings using EditorWindowCaptureSettings. For example:

      EditorWindowCaptureSettings settings = new EditorWindowCaptureSettings(
          width: 1024,
          height: 768,
          delayBeforeCapture: TimeSpan.FromSeconds(0.5)
      );
      

      Note: You can use EditorWindowCaptureSettings.Default for a default 512 × 512 capture with no delay.

    3. Use the EditorWindowCapture.CaptureAsync API to capture the window. For example:

      Texture2D capture = await EditorWindowCapture.CaptureAsync(window, settings);
      

    You can also pass in actions to the window before you capture it using a (window) setup action. For example the following changes the window title:

    EditorWindowCaptureSettings settings = new EditorWindowCaptureSettings(
        ...
        (window) => { window.titleContent = new GUIContent("Test Window"); }
    )
    

    For more information, refer to Asynchronous tests.

    Capture the Scene view

    If you capture the Scene view window, you can use a SceneViewCaptureSettings object instead of an EditorWindowCaptureSettings object, and set two additional settings:

    • ImageComparisonViewpoint: Sets the Scene view camera transform before capture to ensure a consistent viewpoint.
    • Timeout: Sets a timeout for async operations such as shader compilation, to avoid indefinite waits.

    You can use SceneViewCaptureSettings.Default to create settings for a standard Scene view capture.

    Additional resources

    • Write a scene test
    • Graphics Tests window reference
    • Run a graphics test for the first time
    In This Article
    Back to top
    Copyright © 2026 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)