EditorGUILayout.TagField 标签字段

static function TagField (tag : string, params options : GUILayoutOption[]) : string
static function TagField (tag : string, style : GUIStyle, params options : GUILayoutOption[]) : string
static function TagField (label : string, tag : string, params options : GUILayoutOption[]) : string
static function TagField (label : string, tag : string, style : GUIStyle, params options : GUILayoutOption[]) : string
static function TagField (label : GUIContent, tag : string, params options : GUILayoutOption[]) : string
static function TagField (label : GUIContent, tag : string, style : GUIStyle, params options : GUILayoutOption[]) : string

Parameters参数

Returns

string - The tag selected by the user.

返回字符串,用户选择的标签。

Description描述

Make a tag selection field.

制作一个标签选择字段。

EditorGUILayout.TagField 标签字段

Assign tags on the selected GameObjects
在选择的游戏物体指定标签。

// Simple editor script that lets you set a tag for the selected GameObjects.

//为选择的游戏物体设置标签

class EditorGUILayoutTagField extends EditorWindow {



	var tagStr = "";

	@MenuItem("Examples/Set Tags For Selection")

	static function Init() {

		var window = GetWindow(EditorGUILayoutTagField);

		window.Show();

	}

	//Disable menu if we dont have at least 1 gameobject selected

	//如果没有选择游戏物体,禁用菜单

	@MenuItem("Examples/Set Tags For Selection", true)

	static function ValidateSelection() {

		return Selection.activeGameObject != null;

	}



	function OnGUI() {

		tagStr = EditorGUILayout.TagField("Tag for Objects:",tagStr);

		if(GUILayout.Button("Set Tag!"))

			SetTags();

	}

	function SetTags() {

		for(var go : GameObject in Selection.gameObjects)

			go.tag = tagStr;

	}

}
Page last updated: 2011-7-14