Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

GUI.depth

マニュアルに切り替える
public static int depth;

説明

現在実行中の GUI 動作のデプス

これは同時に実行されている他のスクリプトの GUI との描画順を制御するために設定します。 depth が低い値の GUI 要素は高い値の GUI 要素より上に描画されます(たとえばカメラからの「距離」をデプスと考えることができます)

注意: この例を動かすにはスクリプトを 2 つ作成する必要があります。 スクリプトファイル名とクラス名を同じにした場合は 動かないことを忘れないようにしましょう。


背後に他のボタン

// 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;
		}
	}
}

そして別のスクリプトにこの例のコードをコピーします

// 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;
		}
	}
}