Skip to content

Instantly share code, notes, and snippets.

View noahjames404's full-sized avatar
🏠
Working from home

noah james noahjames404

🏠
Working from home
View GitHub Profile
@noahjames404
noahjames404 / CustomPreviewExample.cs
Created May 17, 2023 23:54 — forked from chrisyarbrough/CustomPreviewExample.cs
This shows how UnityEditor.PreviewRenderUtility can be used to draw a custom scene and render it interactively in an editor window. The target object can be modified while running, but it is important to note, that in this case we need to managed target instantiation and destruction ourselves.
using UnityEditor;
using UnityEngine;
/// <summary>
/// Demonstrates how to use <see cref="UnityEditor.PreviewRenderUtility"/>
/// to render a small interactive scene in a custom editor window.
/// </summary>
public class CustomPreviewExample : EditorWindow
{
[MenuItem("My Tools/Custom Preview")]