EditorWindow.autoRepaintOnSceneChange

切换到手册
public bool autoRepaintOnSceneChange ;

描述

窗口是否会在场景每次发生变化时自动重绘?

\ 渲染主摄像机“看到”的内容的编辑器窗口。

// Simple script that lets you render the main camera in an editor Window.

using UnityEngine; using UnityEditor;

public class CameraViewer : EditorWindow { Camera camera; RenderTexture renderTexture;

[MenuItem("Example/Camera viewer")] static void Init() { EditorWindow editorWindow = GetWindow(typeof(CameraViewer)); editorWindow.autoRepaintOnSceneChange = true; editorWindow.Show(); }

public void Awake() { renderTexture = new RenderTexture((int)position.width, (int)position.height, (int)RenderTextureFormat.ARGB32); }

public void OnEnable() { camera = Camera.main; }

public void Update() { if (camera != null) { camera.targetTexture = renderTexture; camera.Render(); camera.targetTexture = null; } if (renderTexture.width != position.width || renderTexture.height != position.height) renderTexture = new RenderTexture((int)position.width, (int)position.height, (int)RenderTextureFormat.ARGB32); }

void OnGUI() { GUI.DrawTexture(new Rect(0.0f, 0.0f, position.width, position.height), renderTexture); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961