GUI.depth 深度

static var depth : int

Description描述

The sorting depth of the currently executing GUI behaviour.

当前执行的GUI行为的深度排序。

Set this to determine ordering when you have different scripts running simultaneously.

当你有不同的脚本同时运行,设置这个值来确定排序。

Note:To see this example working, you will need to create 2 scripts. Remember to name the scripts with the same name as the class names, else it will not work.

注意:下面的例子,接下来创建2个脚本文件,记得文件名和类名一样,否则将无法正常运行。

GUI.depth 深度

One Button behind the other.
一个按钮在另一个后面。

这个文件名为example1

using UnityEngine;
using System.Collections;

public class example1 : MonoBehaviour {
	public static int guiDepth = 0;
	void OnGUI() {
		GUI.depth = typeof(guiDepth);
		if (GUI.RepeatButton(new Rect(0, 0, 100, 100), "GoBack")) {
			typeof(guiDepth) = 1;
			example2.guiDepth = 0;
		}
	}
}
public class example : MonoBehaviour {
}
// Makes this button go back in depth over the example2 class one.

class example1 extends MonoBehaviour {
	static var guiDepth : int = 0;
	function OnGUI() {
		GUI.depth = guiDepth;
		if(GUI.RepeatButton(Rect(0,0,100,100), "GoBack")) {
			guiDepth = 1;
			example2.guiDepth = 0;
		}
	}
}

这个文件名为example2

using UnityEngine;
using System.Collections;

public class example2 : MonoBehaviour {
	public static int guiDepth = 1;
	void OnGUI() {
		GUI.depth = typeof(guiDepth);
		if (GUI.RepeatButton(new Rect(50, 50, 100, 100), "GoBack")) {
			typeof(guiDepth) = 1;
			example1.guiDepth = 0;
		}
	}
}
public class example : MonoBehaviour {
}
// Makes this button go back in depth over the example1 class one.

class example2 extends MonoBehaviour {
	static var guiDepth : int = 1;
	function OnGUI() {
		GUI.depth = guiDepth;
		if(GUI.RepeatButton(Rect(50,50,100,100), "GoBack")) {
			guiDepth = 1;
			example1.guiDepth = 0;
		}
	}
}
Page last updated: 2011-6-15