/// <summary> /// Creates a new list box with enumeration entries as its elements and a label. /// </summary> /// <param name="enumType">Type of enum of whose entries to display in the list box.</param> /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one. /// </param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIEnumField(Type enumType, bool multiselect, GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, Enum.GetNames(enumType), Enum.GetValues(enumType), multiselect, title, titleWidth, style, options, true); }
private static extern void Internal_CreateInstance(GUIGameObjectField instance, Type type, GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
/// <summary> /// Updates the contents display on the label. /// </summary> /// <param name="content">Content to display on the label.</param> public void SetContent(GUIContent content) { Internal_SetContent(mCachedPtr, content); }
private static extern void Internal_SetContent(IntPtr nativeInstance, GUIContent content);
private static extern void Internal_CreateInstance(GUITextureField instance, GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
/// <summary> /// Creates a new label element. /// </summary> /// <param name="content">Content to display on the label.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> public GUILabel(GUIContent content, string style = "") { Internal_CreateInstance(this, content, style, new GUIOption[0]); }
/// <summary> /// Rebuilds the GUI object header if needed. /// </summary> /// <param name="layoutIndex">Index at which to insert the GUI elements.</param> protected void BuildGUI(int layoutIndex) { Action BuildEmptyGUI = () => { guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); guiInternalTitleLayout.AddElement(new GUILabel(title)); guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100))); if (!property.IsValueType) { GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create), new LocEdString("Create")); GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30)); createBtn.OnClick += OnCreateButtonClicked; guiInternalTitleLayout.AddElement(createBtn); } }; Action BuildFilledGUI = () => { guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout); guiFoldout.Value = isExpanded; guiFoldout.OnToggled += OnFoldoutToggled; guiInternalTitleLayout.AddElement(guiFoldout); GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear), new LocEdString("Clear")); GUIButton clearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(20)); clearBtn.OnClick += OnClearButtonClicked; guiInternalTitleLayout.AddElement(clearBtn); if (isExpanded) { SerializableObject serializableObject = property.GetObject(); SerializableField[] fields = serializableObject.Fields; if (fields.Length > 0) { guiChildLayout = guiLayout.AddLayoutX(); guiChildLayout.AddSpace(IndentAmount); GUIPanel guiContentPanel = guiChildLayout.AddPanel(); GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX(); guiIndentLayoutX.AddSpace(IndentAmount); GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); GUILayoutY guiContentLayout = guiIndentLayoutY.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiIndentLayoutX.AddSpace(IndentAmount); guiChildLayout.AddSpace(IndentAmount); short backgroundDepth = (short) (Inspector.START_BACKGROUND_DEPTH - depth - 1); string bgPanelStyle = depth%2 == 0 ? EditorStyles.InspectorContentBgAlternate : EditorStyles.InspectorContentBg; GUIPanel backgroundPanel = guiContentPanel.AddPanel(backgroundDepth); GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle); backgroundPanel.AddElement(inspectorContentBg); int currentIndex = 0; foreach (var field in fields) { if (!field.Inspectable) continue; string childPath = path + "/" + field.Name; InspectableField inspectable = CreateInspectable(parent, field.Name, childPath, currentIndex, depth + 1, new InspectableFieldLayout(guiContentLayout), field.GetProperty()); children.Add(inspectable); currentIndex += inspectable.GetNumLayoutElements(); } } } else guiChildLayout = null; }; if (state == State.None) { if (propertyValue != null) { BuildFilledGUI(); state = State.Filled; } else { BuildEmptyGUI(); state = State.Empty; } } else if (state == State.Empty) { if (propertyValue != null) { guiInternalTitleLayout.Destroy(); BuildFilledGUI(); state = State.Filled; } } else if (state == State.Filled) { foreach (var child in children) child.Destroy(); children.Clear(); guiInternalTitleLayout.Destroy(); if (guiChildLayout != null) { guiChildLayout.Destroy(); guiChildLayout = null; } if (propertyValue == null) { BuildEmptyGUI(); state = State.Empty; } else { BuildFilledGUI(); } } }
private static extern void Internal_CreateInstance(GUISliderField instance, float min, float max, GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
/// <summary> /// Creates a new toggle button with the specified label. /// </summary> /// <param name="content">Content to display on the button.</param> /// <param name="toggleGroup">Optional toggle group that is used for grouping multiple toggle buttons /// together.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> public GUIToggle(GUIContent content, GUIToggleGroup toggleGroup, string style) { Internal_CreateInstance(this, content, toggleGroup, style, new GUIOption[0]); }
/// <summary> /// Creates a new toggle button with the specified label. /// </summary> /// <param name="content">Content to display on the button.</param> /// <param name="toggleGroup">Optional toggle group that is used for grouping multiple toggle buttons /// together.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIToggle(GUIContent content, GUIToggleGroup toggleGroup, params GUIOption[] options) { Internal_CreateInstance(this, content, toggleGroup, "", options); }
/// <summary> /// Creates a new toggle button with the specified label. /// </summary> /// <param name="content">Content to display on the button.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIToggle(GUIContent content, params GUIOption[] options) { Internal_CreateInstance(this, content, null, "", options); }
private static extern void Internal_CreateInstance(GUIToggle instance, GUIContent content, GUIToggleGroup toggleGroup, string style, GUIOption[] options);
/// <summary> /// Creates a new single selection list box with enumeration entries as its elements and a label. /// </summary> /// <param name="enumType">Type of enum of whose entries to display in the list box.</param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIEnumField(Type enumType, GUIContent title, int titleWidth, params GUIOption[] options) { Internal_CreateInstance(this, Enum.GetNames(enumType), Enum.GetValues(enumType), false, title, titleWidth, "", options, true); }
/// <summary> /// Creates a new game object field element with a label. /// </summary> /// <param name="type">Specific type of <see cref="GameObject"/> this field accepts.</param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIGameObjectField(Type type, GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, type, title, titleWidth, style, options, true); }
private void OnInitialize() { ProjectLibrary.OnEntryAdded += OnEntryChanged; ProjectLibrary.OnEntryImported += OnEntryChanged; ProjectLibrary.OnEntryRemoved += OnEntryChanged; GUILayoutY contentLayout = GUI.AddLayoutY(); searchBarLayout = contentLayout.AddLayoutX(); searchField = new GUITextField(); searchField.OnChanged += OnSearchChanged; searchField.OnFocusGained += StopRename; GUIContent clearIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Clear), new LocEdString("Clear")); GUIButton clearSearchBtn = new GUIButton(clearIcon); clearSearchBtn.OnClick += OnClearClicked; clearSearchBtn.SetWidth(40); GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options), new LocEdString("Options")); optionsButton = new GUIButton(optionsIcon); optionsButton.OnClick += OnOptionsClicked; optionsButton.SetWidth(40); searchBarLayout.AddElement(searchField); searchBarLayout.AddElement(clearSearchBtn); searchBarLayout.AddElement(optionsButton); folderBarLayout = contentLayout.AddLayoutX(); GUIContent homeIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Home), new LocEdString("Home")); GUIButton homeButton = new GUIButton(homeIcon, GUIOption.FixedWidth(FOLDER_BUTTON_WIDTH)); homeButton.OnClick += OnHomeClicked; GUIContent upIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Up), new LocEdString("Up")); GUIButton upButton = new GUIButton(upIcon, GUIOption.FixedWidth(FOLDER_BUTTON_WIDTH)); upButton.OnClick += OnUpClicked; folderBarLayout.AddElement(homeButton); folderBarLayout.AddElement(upButton); folderBarLayout.AddSpace(10); contentScrollArea = new GUIScrollArea(GUIOption.FlexibleWidth(), GUIOption.FlexibleHeight()); contentLayout.AddElement(contentScrollArea); contentLayout.AddFlexibleSpace(); entryContextMenu = LibraryMenu.CreateContextMenu(this); content = new LibraryGUIContent(this, contentScrollArea); Refresh(); dropTarget = new LibraryDropTarget(this); dropTarget.Bounds = GetScrollAreaBounds(); dropTarget.OnStart += OnDragStart; dropTarget.OnDrag += OnDragMove; dropTarget.OnLeave += OnDragLeave; dropTarget.OnDropResource += OnResourceDragDropped; dropTarget.OnDropSceneObject += OnSceneObjectDragDropped; dropTarget.OnEnd += OnDragEnd; Selection.OnSelectionChanged += OnSelectionChanged; Selection.OnResourcePing += OnPing; }
/// <summary> /// Recreates the entire curve editor GUI depending on the currently selected scene object. /// </summary> private void RebuildGUI() { GUI.Clear(); guiCurveEditor = null; guiFieldDisplay = null; if (selectedSO == null) { GUILabel warningLbl = new GUILabel(new LocEdString("Select an object to animate in the Hierarchy or Scene windows.")); GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX horzLayout = vertLayout.AddLayoutX(); vertLayout.AddFlexibleSpace(); horzLayout.AddFlexibleSpace(); horzLayout.AddElement(warningLbl); horzLayout.AddFlexibleSpace(); return; } // Top button row GUIContent playIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Play), new LocEdString("Play")); GUIContent recordIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Record), new LocEdString("Record")); GUIContent prevFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameBack), new LocEdString("Previous frame")); GUIContent nextFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameForward), new LocEdString("Next frame")); GUIContent addKeyframeIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddKeyframe), new LocEdString("Add keyframe")); GUIContent addEventIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddEvent), new LocEdString("Add event")); GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options), new LocEdString("Options")); playButton = new GUIToggle(playIcon, EditorStyles.Button); recordButton = new GUIToggle(recordIcon, EditorStyles.Button); prevFrameButton = new GUIButton(prevFrameIcon); frameInputField = new GUIIntField(); nextFrameButton = new GUIButton(nextFrameIcon); addKeyframeButton = new GUIButton(addKeyframeIcon); addEventButton = new GUIButton(addEventIcon); optionsButton = new GUIButton(optionsIcon); playButton.OnToggled += x => { if(x) SwitchState(State.Playback); else SwitchState(State.Normal); }; recordButton.OnToggled += x => { if (x) SwitchState(State.Recording); else SwitchState(State.Normal); }; prevFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx - 1); switch (state) { case State.Recording: case State.Normal: PreviewFrame(currentFrameIdx); break; default: SwitchState(State.Normal); break; } }; frameInputField.OnChanged += x => { SetCurrentFrame(x); switch (state) { case State.Recording: case State.Normal: PreviewFrame(currentFrameIdx); break; default: SwitchState(State.Normal); break; } }; nextFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx + 1); switch (state) { case State.Recording: case State.Normal: PreviewFrame(currentFrameIdx); break; default: SwitchState(State.Normal); break; } }; addKeyframeButton.OnClick += () => { SwitchState(State.Normal); guiCurveEditor.AddKeyFrameAtMarker(); }; addEventButton.OnClick += () => { SwitchState(State.Normal); guiCurveEditor.AddEventAtMarker(); }; optionsButton.OnClick += () => { Vector2I openPosition = ScreenToWindowPos(Input.PointerPosition); AnimationOptions dropDown = DropDownWindow.Open<AnimationOptions>(this, openPosition); dropDown.Initialize(this); }; // Property buttons addPropertyBtn = new GUIButton(new LocEdString("Add property")); delPropertyBtn = new GUIButton(new LocEdString("Delete selected")); addPropertyBtn.OnClick += () => { Action openPropertyWindow = () => { Vector2I windowPos = ScreenToWindowPos(Input.PointerPosition); FieldSelectionWindow fieldSelection = DropDownWindow.Open<FieldSelectionWindow>(this, windowPos); fieldSelection.OnFieldSelected += OnFieldAdded; }; if (clipInfo.clip == null) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("Selected object doesn't have an animation clip assigned. Would you like to create" + " a new animation clip?"); DialogBox.Open(title, message, DialogBox.Type.YesNoCancel, type => { if (type == DialogBox.ResultType.Yes) { string clipSavePath; if (BrowseDialog.SaveFile(ProjectLibrary.ResourceFolder, "*.asset", out clipSavePath)) { SwitchState(State.Empty); clipSavePath = Path.ChangeExtension(clipSavePath, ".asset"); AnimationClip newClip = new AnimationClip(); ProjectLibrary.Create(newClip, clipSavePath); LoadAnimClip(newClip); Animation animation = selectedSO.GetComponent<Animation>(); if (animation == null) animation = selectedSO.AddComponent<Animation>(); animation.DefaultClip = newClip; EditorApplication.SetSceneDirty(); SwitchState(State.Normal); openPropertyWindow(); } } }); } else { if (clipInfo.isImported) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("You cannot add/edit/remove curves from animation clips that" + " are imported from an external file."); DialogBox.Open(title, message, DialogBox.Type.OK); } else { SwitchState(State.Normal); openPropertyWindow(); } } }; delPropertyBtn.OnClick += () => { if (clipInfo.clip == null) return; SwitchState(State.Normal); if (clipInfo.isImported) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("You cannot add/edit/remove curves from animation clips that" + " are imported from an external file."); DialogBox.Open(title, message, DialogBox.Type.OK); } else { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("Are you sure you want to remove all selected fields?"); DialogBox.Open(title, message, DialogBox.Type.YesNo, x => { if (x == DialogBox.ResultType.Yes) { RemoveSelectedFields(); ApplyClipChanges(); } }); } }; GUIPanel mainPanel = GUI.AddPanel(); GUIPanel backgroundPanel = GUI.AddPanel(1); GUILayout mainLayout = mainPanel.AddLayoutY(); buttonLayout = mainLayout.AddLayoutX(); buttonLayout.AddSpace(5); buttonLayout.AddElement(playButton); buttonLayout.AddElement(recordButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(prevFrameButton); buttonLayout.AddElement(frameInputField); buttonLayout.AddElement(nextFrameButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(addKeyframeButton); buttonLayout.AddElement(addEventButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(optionsButton); buttonLayout.AddFlexibleSpace(); buttonLayoutHeight = playButton.Bounds.height; GUITexture buttonBackground = new GUITexture(null, EditorStyles.HeaderBackground); buttonBackground.Bounds = new Rect2I(0, 0, Width, buttonLayoutHeight); backgroundPanel.AddElement(buttonBackground); GUILayout contentLayout = mainLayout.AddLayoutX(); GUILayout fieldDisplayLayout = contentLayout.AddLayoutY(GUIOption.FixedWidth(FIELD_DISPLAY_WIDTH)); guiFieldDisplay = new GUIAnimFieldDisplay(fieldDisplayLayout, FIELD_DISPLAY_WIDTH, Height - buttonLayoutHeight * 2, selectedSO); guiFieldDisplay.OnEntrySelected += OnFieldSelected; GUILayout bottomButtonLayout = fieldDisplayLayout.AddLayoutX(); bottomButtonLayout.AddElement(addPropertyBtn); bottomButtonLayout.AddElement(delPropertyBtn); horzScrollBar = new GUIResizeableScrollBarH(); horzScrollBar.OnScrollOrResize += OnHorzScrollOrResize; vertScrollBar = new GUIResizeableScrollBarV(); vertScrollBar.OnScrollOrResize += OnVertScrollOrResize; GUITexture separator = new GUITexture(null, EditorStyles.Separator, GUIOption.FixedWidth(3)); contentLayout.AddElement(separator); GUILayout curveLayout = contentLayout.AddLayoutY(); GUILayout curveLayoutHorz = curveLayout.AddLayoutX(); GUILayout horzScrollBarLayout = curveLayout.AddLayoutX(); horzScrollBarLayout.AddElement(horzScrollBar); horzScrollBarLayout.AddFlexibleSpace(); editorPanel = curveLayoutHorz.AddPanel(); curveLayoutHorz.AddElement(vertScrollBar); curveLayoutHorz.AddFlexibleSpace(); scrollBarHeight = horzScrollBar.Bounds.height; scrollBarWidth = vertScrollBar.Bounds.width; Vector2I curveEditorSize = GetCurveEditorSize(); guiCurveEditor = new GUICurveEditor(this, editorPanel, curveEditorSize.x, curveEditorSize.y); guiCurveEditor.OnFrameSelected += OnFrameSelected; guiCurveEditor.OnEventAdded += OnEventsChanged; guiCurveEditor.OnEventModified += EditorApplication.SetProjectDirty; guiCurveEditor.OnEventDeleted += OnEventsChanged; guiCurveEditor.OnCurveModified += () => { SwitchState(State.Normal); ApplyClipChanges(); PreviewFrame(currentFrameIdx); EditorApplication.SetProjectDirty(); }; guiCurveEditor.OnClicked += () => { if(state != State.Recording) SwitchState(State.Normal); }; guiCurveEditor.Redraw(); horzScrollBar.SetWidth(curveEditorSize.x); vertScrollBar.SetHeight(curveEditorSize.y); UpdateScrollBarSize(); }
/// <summary> /// Creates a new list box with the specified elements and a label. /// </summary> /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same /// order as in the array.</param> /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one. /// </param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIListBoxField(string[] elements, bool multiselect, GUIContent title, int titleWidth = 100, params GUIOption[] options) { Internal_CreateInstance(this, ToLocalizedElements(elements), multiselect, title, titleWidth, "", options, true); }
/// <summary> /// Creates a new slider field element with a label. /// </summary> /// <param name="min">Minimum boundary of the range to clamp values to.</param> /// <param name="max">Maximum boundary of the range to clamp values to.</param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUISliderField(float min, float max, GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, min, max, title, titleWidth, style, options, true); }
/// <summary> /// Creates a new single-selection list box with the specified elements and a label. /// </summary> /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same /// order as in the array.</param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIListBoxField(string[] elements, GUIContent title, int titleWidth, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, ToLocalizedElements(elements), false, title, titleWidth, style, options, true); }
/// <summary> /// Creates a new texture field element with a label. /// </summary> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUITextureField(GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, title, titleWidth, style, options, true); }
private static extern void Internal_CreateInstance(GUIListBoxField instance, LocString[] entries, bool multiselect, GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
/// <summary> /// Creates a new label element. /// </summary> /// <param name="content">Content to display on the label.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUILabel(GUIContent content, params GUIOption[] options) { Internal_CreateInstance(this, content, "", options); }
/// <summary> /// Creates a new list box with the specified elements and a label. /// </summary> /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same /// order as in the array.</param> /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one. /// </param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as /// default layout options. Style will be retrieved from the active GUISkin. If not specified /// default element style is used.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIListBoxField(LocString[] elements, bool multiselect, GUIContent title, int titleWidth, string style = "", params GUIOption[] options) { Internal_CreateInstance(this, elements, multiselect, title, titleWidth, style, options, true); }
private static extern void Internal_CreateInstance(GUILabel instance, GUIContent content, string style, GUIOption[] options);
/// <summary> /// Creates a new single-selection list box with the specified elements and a label. /// </summary> /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same /// order as in the array.</param> /// <param name="title">Content to display on the label.</param> /// <param name="titleWidth">Width of the title label in pixels.</param> /// <param name="options">Options that allow you to control how is the element positioned and sized. This will /// override any similar options set by style.</param> public GUIListBoxField(LocString[] elements, GUIContent title, int titleWidth = 100, params GUIOption[] options) { Internal_CreateInstance(this, elements, false, title, titleWidth, "", options, true); }
private void OnInitialize() { mainLayout = GUI.AddLayoutY(); GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View), new LocEdString("View")); GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move), new LocEdString("Move")); GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate), new LocEdString("Rotate")); GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale), new LocEdString("Scale")); GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local), new LocEdString("Local")); GUIContent worldIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.World), new LocEdString("World")); GUIContent pivotIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Pivot), new LocEdString("Pivot")); GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center), new LocEdString("Center")); GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap), new LocEdString("Move snap")); GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap), new LocEdString("Rotate snap")); GUIToggleGroup handlesTG = new GUIToggleGroup(); viewButton = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); moveButton = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); scaleButton = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); GUIToggleGroup coordModeTG = new GUIToggleGroup(); localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75)); worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75)); GUIToggleGroup pivotModeTG = new GUIToggleGroup(); pivotButton = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35)); moveSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35)); rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35)); rotateSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35)); viewButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.View); moveButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Move); rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate); scaleButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Scale); localCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.Local); worldCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.World); pivotButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Pivot); centerButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Center); moveSnapButton.OnToggled += (bool active) => OnMoveSnapToggled(active); moveSnapInput.OnChanged += (float value) => OnMoveSnapValueChanged(value); rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active); rotateSnapInput.OnChanged += (float value) => OnRotateSnapValueChanged(value); GUILayout handlesLayout = mainLayout.AddLayoutX(); handlesLayout.AddElement(viewButton); handlesLayout.AddElement(moveButton); handlesLayout.AddElement(rotateButton); handlesLayout.AddElement(scaleButton); handlesLayout.AddSpace(10); handlesLayout.AddElement(localCoordButton); handlesLayout.AddElement(worldCoordButton); handlesLayout.AddSpace(10); handlesLayout.AddElement(pivotButton); handlesLayout.AddElement(centerButton); handlesLayout.AddFlexibleSpace(); handlesLayout.AddElement(moveSnapButton); handlesLayout.AddElement(moveSnapInput); handlesLayout.AddSpace(10); handlesLayout.AddElement(rotateSnapButton); handlesLayout.AddElement(rotateSnapInput); GUIPanel mainPanel = mainLayout.AddPanel(); rtPanel = mainPanel.AddPanel(); selectionPanel = mainPanel.AddPanel(-1); GUIPanel sceneAxesPanel = mainPanel.AddPanel(-1); sceneAxesGUI = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective); focusCatcher = new GUIButton("", EditorStyles.Blank); focusCatcher.OnFocusGained += () => hasContentFocus = true; focusCatcher.OnFocusLost += () => hasContentFocus = false; GUIPanel focusPanel = GUI.AddPanel(-2); focusPanel.AddElement(focusCatcher); toggleProfilerOverlayKey = new VirtualButton(ToggleProfilerOverlayBinding); viewToolKey = new VirtualButton(ViewToolBinding); moveToolKey = new VirtualButton(MoveToolBinding); rotateToolKey = new VirtualButton(RotateToolBinding); scaleToolKey = new VirtualButton(ScaleToolBinding); frameKey = new VirtualButton(FrameBinding); UpdateRenderTexture(Width, Height - HeaderHeight); UpdateProfilerOverlay(); }
private static extern void Internal_CreateInstance(GUIEnumField instance, string[] names, Array values, bool multiselect, GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);