/// <summary> /// Stops a rename operation over the entry, hiding the rename input box. /// </summary> public void StopRename() { if (renameTextBox != null) { renameTextBox.Destroy(); renameTextBox = null; } }
private static extern void Internal_CreateInstance(GUITextBox instance, bool multiline, string style, GUIOption[] options);
/// <summary> /// Starts a rename operation over the entry, displaying the rename input box. /// </summary> public void StartRename() { if (renameTextBox != null) return; renameTextBox = new GUITextBox(true); Rect2I renameBounds = label.Bounds; // Rename box allows for less space for text than label, so adjust it slightly so it's more likely to be able // to display all visible text. renameBounds.x -= 4; renameBounds.width += 8; renameBounds.height += 8; renameTextBox.Bounds = renameBounds; owner.RenameOverlay.AddElement(renameTextBox); string name = Path.GetFileNameWithoutExtension(PathEx.GetTail(path)); renameTextBox.Text = name; renameTextBox.Focus = true; }
private void OnInitialize() { GUILabel title = new GUILabel(new LocEdString("Banshee Engine v0.3"), EditorStyles.TitleLabel); GUILabel subTitle = new GUILabel(new LocEdString("A modern open-source game development toolkit"), EditorStyles.LabelCentered); GUILabel license = new GUILabel(new LocEdString( "This program is licensed under the GNU General Public License V3"), EditorStyles.LabelCentered); GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2015 Marko Pintera. All rights reserved."), EditorStyles.LabelCentered); GUILabel emailTitle = new GUILabel(new LocEdString("E-mail"), GUIOption.FixedWidth(150)); emailLabel = new GUITextBox(); GUILabel linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150)); GUIButton linkedInBtn = new GUIButton(new LocEdString("Profile")); GUIToggleGroup foldoutGroup = new GUIToggleGroup(true); GUIToggle contactFoldout = new GUIToggle(new LocEdString("Author contact"), foldoutGroup, EditorStyles.Foldout); GUIToggle thirdPartyFoldout = new GUIToggle(new LocEdString("Used third party libraries"), foldoutGroup, EditorStyles.Foldout); GUIToggle noticesFoldout = new GUIToggle(new LocEdString("Third party notices"), foldoutGroup, EditorStyles.Foldout); GUIToggle collaboratorsFoldout = new GUIToggle(new LocEdString("Collaborators"), foldoutGroup, EditorStyles.Foldout); GUILabel freeTypeNotice = new GUILabel(new LocEdString( "Portions of this software are copyright (C) 2015 The FreeType Project (www.freetype.org). " + "All rights reserved."), EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380)); GUILabel fbxSdkNotice = new GUILabel(new LocEdString( "This software contains Autodesk(R) FBX(R) code developed by Autodesk, Inc. Copyright 2013 Autodesk, Inc. " + "All rights, reserved. Such code is provided \"as is\" and Autodesk, Inc. disclaims any and all warranties, " + "whether express or implied, including without limitation the implied warranties of merchantability, " + "fitness for a particular purpose or non-infringement of third party rights. In no event shall Autodesk, " + "Inc. be liable for any direct, indirect, incidental, special, exemplary, or consequential damages " + "(including, but not limited to, procurement of substitute goods or services; loss of use, data, or " + "profits; or business interruption) however caused and on any theory of liability, whether in contract, " + "strict liability, or tort (including negligence or otherwise) arising in any way out of such code."), EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380)); GUILayoutY mainLayout = GUI.AddLayoutY(); mainLayout.AddSpace(10); mainLayout.AddElement(title); mainLayout.AddElement(subTitle); mainLayout.AddSpace(10); mainLayout.AddElement(license); mainLayout.AddElement(copyright); mainLayout.AddSpace(10); mainLayout.AddElement(contactFoldout); GUILayoutY contactLayout = mainLayout.AddLayoutY(); GUILayout emailLayout = contactLayout.AddLayoutX(); emailLayout.AddSpace(10); emailLayout.AddElement(emailTitle); emailLayout.AddElement(emailLabel); emailLayout.AddSpace(10); GUILayout linkedInLayout = contactLayout.AddLayoutX(); linkedInLayout.AddSpace(10); linkedInLayout.AddElement(linkedInTitle); linkedInLayout.AddElement(linkedInBtn); linkedInLayout.AddSpace(10); mainLayout.AddSpace(5); mainLayout.AddElement(thirdPartyFoldout); GUILayoutY thirdPartyLayout = mainLayout.AddLayoutY(); CreateThirdPartyGUI(thirdPartyLayout, "Autodesk FBX SDK", "http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=10775847", "FBX_SDK_License.rtf"); CreateThirdPartyGUI(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/", "freeimage-license.txt"); CreateThirdPartyGUI(thirdPartyLayout, "FreeType", "http://www.freetype.org/", "FTL.TXT"); CreateThirdPartyGUI(thirdPartyLayout, "Mono", "http://www.mono-project.com/", "Mono.txt"); CreateThirdPartyGUI(thirdPartyLayout, "NVIDIA Texture Tools", "https://github.com/castano/nvidia-texture-tools", "NVIDIATextureTools.txt"); mainLayout.AddSpace(5); mainLayout.AddElement(noticesFoldout); GUILayout noticesLayout = mainLayout.AddLayoutY(); noticesLayout.AddElement(freeTypeNotice); noticesLayout.AddSpace(10); noticesLayout.AddElement(fbxSdkNotice); mainLayout.AddSpace(5); mainLayout.AddElement(collaboratorsFoldout); GUILayoutY collaboratorsLayout = mainLayout.AddLayoutY(); CreateCollaboratorGUI(collaboratorsLayout, "Danijel Ribic", "Logo, UI icons, 3D models & textures"); mainLayout.AddFlexibleSpace(); contactLayout.Active = false; contactFoldout.OnToggled += x => { contactLayout.Active = x; }; thirdPartyLayout.Active = false; thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x; noticesLayout.Active = false; noticesFoldout.OnToggled += x => noticesLayout.Active = x; collaboratorsLayout.Active = false; collaboratorsFoldout.OnToggled += x => collaboratorsLayout.Active = x; emailLabel.Text = "*****@*****.**"; linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("http://hr.linkedin.com/in/markopintera"); }; }
/// <summary> /// Destroys all inspector GUI elements. /// </summary> internal void Clear() { for (int i = 0; i < inspectorComponents.Count; i++) { inspectorComponents[i].foldout.Destroy(); inspectorComponents[i].removeBtn.Destroy(); inspectorComponents[i].inspector.Destroy(); } inspectorComponents.Clear(); if (inspectorResource != null) { inspectorResource.inspector.Destroy(); inspectorResource = null; } if (inspectorScrollArea != null) { inspectorScrollArea.Destroy(); inspectorScrollArea = null; } if (scrollAreaHighlight != null) { scrollAreaHighlight.Destroy(); scrollAreaHighlight = null; } if (highlightPanel != null) { highlightPanel.Destroy(); highlightPanel = null; } activeSO = null; soNameInput = null; soActiveToggle = null; soPrefabLayout = null; soHasPrefab = false; soPosX = null; soPosY = null; soPosZ = null; soRotX = null; soRotY = null; soRotZ = null; soScaleX = null; soScaleY = null; soScaleZ = null; dropAreas = new Rect2I[0]; activeResource = null; currentType = InspectorType.None; }
/// <summary> /// Creates GUI elements required for displaying <see cref="SceneObject"/> fields like name, prefab data and /// transform (position, rotation, scale). Assumes that necessary inspector scroll area layout has already been /// created. /// </summary> private void CreateSceneObjectFields() { GUIPanel sceneObjectPanel = inspectorLayout.AddPanel(); sceneObjectPanel.SetHeight(GetTitleBounds().height); GUILayoutY sceneObjectLayout = sceneObjectPanel.AddLayoutY(); sceneObjectLayout.SetPosition(PADDING, PADDING); GUIPanel sceneObjectBgPanel = sceneObjectPanel.AddPanel(1); GUILayoutX nameLayout = sceneObjectLayout.AddLayoutX(); soActiveToggle = new GUIToggle(""); soActiveToggle.OnToggled += OnSceneObjectActiveStateToggled; GUILabel nameLbl = new GUILabel(new LocEdString("Name"), GUIOption.FixedWidth(50)); soNameInput = new GUITextBox(false, GUIOption.FlexibleWidth(180)); soNameInput.Text = activeSO.Name; soNameInput.OnChanged += OnSceneObjectRename; soNameInput.OnConfirmed += OnModifyConfirm; soNameInput.OnFocusLost += OnModifyConfirm; nameLayout.AddElement(soActiveToggle); nameLayout.AddSpace(3); nameLayout.AddElement(nameLbl); nameLayout.AddElement(soNameInput); nameLayout.AddFlexibleSpace(); soPrefabLayout = sceneObjectLayout.AddLayoutX(); GUILayoutX positionLayout = sceneObjectLayout.AddLayoutX(); GUILabel positionLbl = new GUILabel(new LocEdString("Position"), GUIOption.FixedWidth(50)); soPosX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soPosY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soPosZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soPosX.OnChanged += (x) => OnPositionChanged(0, x); soPosY.OnChanged += (y) => OnPositionChanged(1, y); soPosZ.OnChanged += (z) => OnPositionChanged(2, z); soPosX.OnConfirmed += OnModifyConfirm; soPosY.OnConfirmed += OnModifyConfirm; soPosZ.OnConfirmed += OnModifyConfirm; soPosX.OnFocusLost += OnModifyConfirm; soPosY.OnFocusLost += OnModifyConfirm; soPosZ.OnFocusLost += OnModifyConfirm; positionLayout.AddElement(positionLbl); positionLayout.AddElement(soPosX); positionLayout.AddSpace(10); positionLayout.AddFlexibleSpace(); positionLayout.AddElement(soPosY); positionLayout.AddSpace(10); positionLayout.AddFlexibleSpace(); positionLayout.AddElement(soPosZ); positionLayout.AddFlexibleSpace(); GUILayoutX rotationLayout = sceneObjectLayout.AddLayoutX(); GUILabel rotationLbl = new GUILabel(new LocEdString("Rotation"), GUIOption.FixedWidth(50)); soRotX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soRotY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soRotZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soRotX.OnChanged += (x) => OnRotationChanged(0, x); soRotY.OnChanged += (y) => OnRotationChanged(1, y); soRotZ.OnChanged += (z) => OnRotationChanged(2, z); soRotX.OnConfirmed += OnModifyConfirm; soRotY.OnConfirmed += OnModifyConfirm; soRotZ.OnConfirmed += OnModifyConfirm; soRotX.OnFocusLost += OnModifyConfirm; soRotY.OnFocusLost += OnModifyConfirm; soRotZ.OnFocusLost += OnModifyConfirm; rotationLayout.AddElement(rotationLbl); rotationLayout.AddElement(soRotX); rotationLayout.AddSpace(10); rotationLayout.AddFlexibleSpace(); rotationLayout.AddElement(soRotY); rotationLayout.AddSpace(10); rotationLayout.AddFlexibleSpace(); rotationLayout.AddElement(soRotZ); rotationLayout.AddFlexibleSpace(); GUILayoutX scaleLayout = sceneObjectLayout.AddLayoutX(); GUILabel scaleLbl = new GUILabel(new LocEdString("Scale"), GUIOption.FixedWidth(50)); soScaleX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soScaleY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soScaleZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soScaleX.OnChanged += (x) => OnScaleChanged(0, x); soScaleY.OnChanged += (y) => OnScaleChanged(1, y); soScaleZ.OnChanged += (z) => OnScaleChanged(2, z); soScaleX.OnConfirmed += OnModifyConfirm; soScaleY.OnConfirmed += OnModifyConfirm; soScaleZ.OnConfirmed += OnModifyConfirm; soScaleX.OnFocusLost += OnModifyConfirm; soScaleY.OnFocusLost += OnModifyConfirm; soScaleZ.OnFocusLost += OnModifyConfirm; scaleLayout.AddElement(scaleLbl); scaleLayout.AddElement(soScaleX); scaleLayout.AddSpace(10); scaleLayout.AddFlexibleSpace(); scaleLayout.AddElement(soScaleY); scaleLayout.AddSpace(10); scaleLayout.AddFlexibleSpace(); scaleLayout.AddElement(soScaleZ); scaleLayout.AddFlexibleSpace(); sceneObjectLayout.AddFlexibleSpace(); GUITexture titleBg = new GUITexture(null, EditorStyles.InspectorTitleBg); sceneObjectBgPanel.AddElement(titleBg); }