EditorWindow.autoRepaintOnSceneChange 当场景改变自动重绘

var autoRepaintOnSceneChange : bool

Description描述

Does the window automatically repaint whenever the scene has changed?

每当场景改变,窗口自动重绘?

EditorWindow.autoRepaintOnSceneChange 当场景改变自动重绘

Editor Window that renders what the main camera is "seeing".

编辑器窗口渲染主相机看到的。

// C# example
// Simple script that lets you render the main camera in an editor Window.
//让你在编辑器窗口渲染主相机的简单脚本
using UnityEngine;
using UnityEditor;

public class CameraViewer : EditorWindow {
	Camera camera = Camera.main;
	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 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 );
	}
}
最后修改:2011年5月29日 Sunday 11:36

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。