EditorGUI.LayerField 层字段

static function LayerField (position : Rect, layer : int, style : GUIStyle = EditorStyles.popup) : int
static function LayerField (position : Rect, label : string, layer : int, style : GUIStyle = EditorStyles.popup) : int
static function LayerField (position : Rect, label : GUIContent, layer : int, style : GUIStyle = EditorStyles.popup) : int

Parameters参数

Returns

int - The layer selected by the user.

返回整数 - 用户选择的层。

Description描述

Make a layer selection field.

制作一个层选择字段。

EditorGUI.LayerField 层字段

Layer field in an Editor Window.
在编辑在中的层字段。

// Change the Tag and/or the layer of the selected GameObjects.

//更改标签 和/或 所选游戏物体的层

class EditorGUITagLayerField extends EditorWindow {



	var selectedTag : String = "";

	var selectedLayer : int = 0;



	@MenuItem("Examples/Tag - Layer for Selection")

	static function Init() {

		var window = GetWindow(EditorGUITagLayerField);

		window.position = Rect(0,0,350,70);

		window.Show();

	}



	function OnGUI() {

		selectedTag = EditorGUI.TagField(

			Rect(3,3,position.width/2 - 6, 20),

			"New Tag:",

			selectedTag);

		selectedLayer = EditorGUI.LayerField(

			Rect(position.width/2 + 3,3, position.width/2 - 6, 20),

			"New Layer:",

			selectedLayer);



		if(Selection.activeGameObject) {

			if(GUI.Button(Rect(3,25,90,17),"Change Tags"))

				for(var go : GameObject in Selection.gameObjects)

					go.tag = selectedTag;

			if(GUI.Button(Rect(position.width-96, 25,90,17),"Change Layers"))

				for(var go : GameObject in Selection.gameObjects)

					go.layer = selectedLayer;

		}

	}



	function OnInspectorUpdate() {

		Repaint();

	}

}
Page last updated: 2011-6-22