EditorWindow.OnLostFocus 当失去焦点

function OnLostFocus () : void

Description描述

Called when the window loses keyboard focus.

当窗口失去键盘焦点时调用。

参见:OnFocus.

EditorWindow.OnLostFocus 当失去焦点

Restores normal view when you lose focus on this window.
当丢失这个窗口焦点时,恢复正常视图。

// Simple script that lets you preview your main camera in Orthographic view
// when selected.
//当选择时,在正交视图预览主相机
class OrthographicPreviewer extends EditorWindow {
	var renderTexture : RenderTexture;
	var camera = Camera.main;
	@MenuItem("Example/Camera Selector")
	static function Init() {
		var window = GetWindow(OrthographicPreviewer);
		window.Show();
	}
	function Awake () {
		renderTexture =
		new RenderTexture(position.width, position.height, RenderTextureFormat.ARGB32 );
	}
	function OnInspectorUpdate() {
		this.Repaint();
	}
	function OnGUI() {
		if(GUILayout.Button("Close")) {
			camera.orthographic = false;
			this.Close();
		}
		GUI.DrawTexture(Rect( 0.0f, 50.0f, position.width, position.height), renderTexture);
	}
	function OnFocus() {
		Selection.activeTransform = camera.transform;
		camera.orthographic = true;
	}
	function Update() {
		if(camera != null) {
			camera.targetTexture = renderTexture;
			camera.Render();
			camera.targetTexture = null;
		}
		if(renderTexture.width != position.width || renderTexture.height != position.height)
			renderTexture = new RenderTexture(position.width,
				position.height,
				RenderTextureFormat.ARGB32 );
	}
	function OnLostFocus() {
		camera.orthographic = false;
	}
}
最后修改:2011年6月24日 Friday 15:02

本脚本参考基于Unity 3.4.1f5

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