EditorGUILayout.LayerFieldstatic function LayerField (layer : int, params options : GUILayoutOption[]) : intstatic function LayerField (layer : int, style : GUIStyle, params options : GUILayoutOption[]) : intstatic function LayerField (label : String, layer : int, params options : GUILayoutOption[]) : intstatic function LayerField (label : String, layer : int, style : GUIStyle, params options : GUILayoutOption[]) : intstatic function LayerField (label : GUIContent, layer : int, params options : GUILayoutOption[]) : intstatic function LayerField (label : GUIContent, layer : int, style : GUIStyle, params options : GUILayoutOption[]) : intParameters
Returnsint - The layer selected by the user. DescriptionMake a layer selection field.
// Simple editor script that lets you set the layer for the selected GameObjects. class EditorGUILayoutLayerField extends EditorWindow { var selectedLayer : int = 0; @MenuItem("Examples/Set Layer For Selection") static function Init() { var window = GetWindow(EditorGUILayoutLayerField); window.Show(); } //Disable menu if we dont have at least 1 gameobject selected @MenuItem("Examples/Set Layer For Selection", true) static function ValidateSelection() { return Selection.activeGameObject != null; } function OnGUI() { selectedLayer = EditorGUILayout.LayerField("Layer for Objects:",selectedLayer); if(GUILayout.Button("Set Layer!")) SetLayer(); } function SetLayer() { for(var go : GameObject in Selection.gameObjects) go.layer = selectedLayer; } }
|

