/// <summary> /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before /// use. /// </summary> /// <param name="parent">Scene window that this drop down window is a part of.</param> /// <param name="cameraOptions">Reference to the current scene camera options.</param> internal void Initialize(SceneWindow parent) { this.Parent = parent; GUIEnumField cameraProjectionTypeField = new GUIEnumField(typeof(ProjectionType), new LocEdString("Projection type")); cameraProjectionTypeField.Value = (ulong)Parent.ProjectionType; cameraProjectionTypeField.OnSelectionChanged += SetCameraProjectionType; nearClipPlaneInput = new GUIFloatField(new LocEdString("Near plane")); nearClipPlaneInput.Value = Parent.NearClipPlane; nearClipPlaneInput.OnChanged += OnNearClipPlaneChanged; nearClipPlaneInput.SetRange(SceneCameraOptions.MinNearClipPlane, SceneCameraOptions.MaxNearClipPlane); farClipPlaneInput = new GUIFloatField(new LocEdString("Far plane")); farClipPlaneInput.Value = Parent.FarClipPlane; farClipPlaneInput.OnChanged += OnFarClipPlaneChanged; farClipPlaneInput.SetRange(SceneCameraOptions.MinFarClipPlane, SceneCameraOptions.MaxFarClipPlane); cameraFieldOfView = new GUISliderField(1, 360, new LocEdString("Field of view")); cameraFieldOfView.Value = Parent.FieldOfView.Degrees; cameraFieldOfView.OnChanged += SetFieldOfView; cameraOrthographicSize = new GUIFloatField(new LocEdString("Orthographic size")); cameraOrthographicSize.Value = Parent.OrthographicSize; cameraOrthographicSize.OnChanged += SetOrthographicSize; GUISliderField cameraScrollSpeed = new GUISliderField(SceneCameraOptions.MinScrollSpeed, SceneCameraOptions.MaxScrollSpeed, new LocEdString("Scroll speed")); cameraScrollSpeed.Value = Parent.ScrollSpeed; cameraScrollSpeed.OnChanged += SetScrollSpeed; GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddSpace(10); GUILayoutX cameraOptionsLayoutX = vertLayout.AddLayoutX(); cameraOptionsLayoutX.AddSpace(10); GUILayoutY cameraOptionsLayoutY = cameraOptionsLayoutX.AddLayoutY(); cameraOptionsLayoutY.AddElement(cameraProjectionTypeField); cameraOptionsLayoutY.AddElement(nearClipPlaneInput); cameraOptionsLayoutY.AddElement(farClipPlaneInput); cameraOptionsLayoutY.AddElement(cameraFieldOfView); cameraOptionsLayoutY.AddElement(cameraOrthographicSize); cameraOptionsLayoutY.AddElement(cameraScrollSpeed); cameraOptionsLayoutX.AddSpace(10); vertLayout.AddSpace(10); ToggleTypeSpecificFields((ProjectionType)cameraProjectionTypeField.Value); }
private void OnInitialize() { GUILayoutY mainLayout = GUI.AddLayoutY(); string[] aspectRatioTitles = new string[aspectRatios.Length + 1]; aspectRatioTitles[0] = "Free"; for (int i = 0; i < aspectRatios.Length; i++) { aspectRatioTitles[i + 1] = aspectRatios[i].width + ":" + aspectRatios[i].height; } GUIListBoxField aspectField = new GUIListBoxField(aspectRatioTitles, new LocEdString("Aspect ratio")); aspectField.OnSelectionChanged += OnAspectRatioChanged; GUILayoutY buttonLayoutVert = mainLayout.AddLayoutY(); GUILayoutX buttonLayout = buttonLayoutVert.AddLayoutX(); buttonLayout.AddElement(aspectField); buttonLayout.AddFlexibleSpace(); buttonLayoutVert.AddFlexibleSpace(); renderTextureGUI = new GUIRenderTexture(null); renderTextureBg = new GUITexture(Builtin.WhiteTexture); renderTextureBg.SetTint(BG_COLOR); noCameraLabel = new GUILabel(new LocEdString("(No main camera in scene)")); GUIPanel rtPanel = mainLayout.AddPanel(); rtPanel.AddElement(renderTextureGUI); GUIPanel bgPanel = rtPanel.AddPanel(1); bgPanel.AddElement(renderTextureBg); GUILayoutY alignLayoutY = rtPanel.AddLayoutY(); alignLayoutY.AddFlexibleSpace(); GUILayoutX alignLayoutX = alignLayoutY.AddLayoutX(); alignLayoutX.AddFlexibleSpace(); alignLayoutX.AddElement(noCameraLabel); alignLayoutX.AddFlexibleSpace(); alignLayoutY.AddFlexibleSpace(); UpdateRenderTexture(Width, Height); bool hasMainCamera = Scene.Camera != null; renderTextureGUI.Active = hasMainCamera; noCameraLabel.Active = !hasMainCamera; }
private void OnInitialize() { GUILayout vertLayout = GUI.AddLayoutY(); GUILayout editorPanel = vertLayout.AddPanel(GUIOption.FixedHeight(400)); GUILayout buttonLayout = vertLayout.AddLayoutX(GUIOption.FixedHeight(40)); guiOK = new GUIButton(new LocEdString("OK")); guiCancel = new GUIButton(new LocEdString("Cancel")); guiOK.OnClick += OnOK; guiCancel.OnClick += OnCancel; CurveDrawOptions drawOptions = CurveDrawOptions.DrawKeyframes | CurveDrawOptions.DrawMarkers; if (curveB != null) { drawOptions |= CurveDrawOptions.DrawRange; } curveEditor = new GUICurveEditor(editorPanel, 600, 400, false, drawOptions); curveEditor.Redraw(); EdCurveDrawInfo[] drawinfo; if (curveB != null) { drawinfo = new [] { new EdCurveDrawInfo(curveA, Color.BansheeOrange), new EdCurveDrawInfo(curveB, Color.Green), }; } else { drawinfo = new [] { new EdCurveDrawInfo(curveA, Color.BansheeOrange), }; } curveEditor.SetCurves(drawinfo); curveEditor.CenterAndResize(true); buttonLayout.AddFlexibleSpace(); buttonLayout.AddElement(guiOK); buttonLayout.AddSpace(10); buttonLayout.AddElement(guiCancel); buttonLayout.AddFlexibleSpace(); EditorInput.OnPointerPressed += OnPointerPressed; EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked; EditorInput.OnPointerMoved += OnPointerMoved; EditorInput.OnPointerReleased += OnPointerReleased; EditorInput.OnButtonUp += OnButtonUp; }
/// <summary> /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before /// use. /// </summary> /// <param name="parent">Animation window that this drop down window is a part of.</param> internal void Initialize(AnimationWindow parent) { GUIIntField fpsField = new GUIIntField(new LocEdString("FPS"), 40); fpsField.Value = parent.FPS; fpsField.OnChanged += x => { parent.FPS = x; }; GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX contentLayout = vertLayout.AddLayoutX(); contentLayout.AddFlexibleSpace(); contentLayout.AddElement(fpsField); contentLayout.AddFlexibleSpace(); vertLayout.AddFlexibleSpace(); }
private void BuildGUI() { progressBar = new GUIProgressBar(); messageLabel = new GUILabel("", EditorStyles.MultiLineLabelCentered, GUIOption.FixedHeight(60)); cancelImport = new GUIButton(new LocEdString("Cancel import")); cancelImport.OnClick += () => { ProjectLibrary.CancelImport(); cancelImport.Disabled = true; }; GUILayoutY layoutY = GUI.AddLayoutY(); layoutY.AddFlexibleSpace(); GUILayoutX messageLayout = layoutY.AddLayoutX(); messageLayout.AddSpace(15); messageLayout.AddElement(messageLabel); messageLayout.AddSpace(15); layoutY.AddSpace(10); GUILayoutX barLayout = layoutY.AddLayoutX(); barLayout.AddSpace(30); barLayout.AddElement(progressBar); barLayout.AddSpace(30); layoutY.AddSpace(20); GUILayoutX buttonLayout = layoutY.AddLayoutX(); buttonLayout.AddFlexibleSpace(); buttonLayout.AddElement(cancelImport); buttonLayout.AddFlexibleSpace(); layoutY.AddFlexibleSpace(); messageLabel.SetContent(new LocEdString("Resource import is still in progress. You can wait until it " + "finishes or cancel import. \n\nNote that even when cancelling you will need to wait for active import threads to finish.")); }
/// <summary> /// Common code called by both Initialize() overloads. /// </summary> /// <param name="gui">GUI panel to add the GUI elements to.</param> /// <param name="persistent">A set of properties that the inspector can read/write. They will be persisted even /// after the inspector is closed and restored when it is re-opened.</param> private void InitializeBase(GUIPanel gui, SerializableProperties persistent) { rootGUI = gui; this.persistent = persistent; GUILayout contentLayoutX = gui.AddLayoutX(); contentLayoutX.AddSpace(5); GUILayout contentLayoutY = contentLayoutX.AddLayoutY(); contentLayoutY.AddSpace(5); GUIPanel contentPanel = contentLayoutY.AddPanel(); contentLayoutY.AddSpace(5); contentLayoutX.AddSpace(5); GUIPanel backgroundPanel = gui.AddPanel(START_BACKGROUND_DEPTH); GUITexture inspectorContentBg = new GUITexture(null, EditorStylesInternal.InspectorContentBg); backgroundPanel.AddElement(inspectorContentBg); mainPanel = contentPanel; layout = GUI.AddLayoutY(); }
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)); GUIContent cameraOptionsIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.SceneCameraOptions), new LocEdString("Camera options")); cameraOptionsButton = new GUIButton(cameraOptionsIcon); 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); cameraOptionsButton.OnClick += () => OnCameraOptionsClicked(); 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); handlesLayout.AddSpace(10); handlesLayout.AddElement(cameraOptionsButton); handlesLayout.SetHeight(viewButton.Bounds.height); GUIPanel mainPanel = mainLayout.AddPanel(); rtPanel = mainPanel.AddPanel(); // Loading progress loadLabel = new GUILabel(new LocEdString("Loading scene...")); loadProgressBar = new GUIProgressBar("", GUIOption.FixedWidth(200)); progressLayout = mainPanel.AddLayoutY(); progressLayout.AddFlexibleSpace(); GUILayout loadLabelLayout = progressLayout.AddLayoutX(); loadLabelLayout.AddFlexibleSpace(); loadLabelLayout.AddElement(loadLabel); loadLabelLayout.AddFlexibleSpace(); GUILayout progressBarLayout = progressLayout.AddLayoutX(); progressBarLayout.AddFlexibleSpace(); progressBarLayout.AddElement(loadProgressBar); progressBarLayout.AddFlexibleSpace(); progressLayout.AddFlexibleSpace(); progressLayout.Active = false; selectionPanel = mainPanel.AddPanel(-1); 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); viewToolKey = new VirtualButton(ViewToolBinding); moveToolKey = new VirtualButton(MoveToolBinding); rotateToolKey = new VirtualButton(RotateToolBinding); scaleToolKey = new VirtualButton(ScaleToolBinding); frameKey = new VirtualButton(FrameBinding); UpdateRenderTexture(Width, Height - HeaderHeight); UpdateLoadingProgress(); }
private void OnInitialize() { GUILayoutY layout = GUI.AddLayoutY(); GUILayoutX titleLayout = layout.AddLayoutX(); GUIContentImages infoImages = new GUIContentImages( EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, false), EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, true)); GUIContentImages warningImages = new GUIContentImages( EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, false), EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, true)); GUIContentImages errorImages = new GUIContentImages( EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, false), EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, true)); GUIToggle infoBtn = new GUIToggle(new GUIContent(infoImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle warningBtn = new GUIToggle(new GUIContent(warningImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle errorBtn = new GUIToggle(new GUIContent(errorImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle detailsBtn = new GUIToggle(new LocEdString("Show details"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIButton clearBtn = new GUIButton(new LocEdString("Clear"), GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle clearOnPlayBtn = new GUIToggle(new LocEdString("Clear on play"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); titleLayout.AddElement(infoBtn); titleLayout.AddElement(warningBtn); titleLayout.AddElement(errorBtn); titleLayout.AddFlexibleSpace(); titleLayout.AddElement(detailsBtn); titleLayout.AddElement(clearBtn); titleLayout.AddElement(clearOnPlayBtn); infoBtn.Value = filter.HasFlag(EntryFilter.Info); warningBtn.Value = filter.HasFlag(EntryFilter.Warning); errorBtn.Value = filter.HasFlag(EntryFilter.Error); clearOnPlayBtn.Value = EditorSettings.GetBool(CLEAR_ON_PLAY_KEY, true); infoBtn.OnToggled += x => { if (x) { SetFilter(filter | EntryFilter.Info); } else { SetFilter(filter & ~EntryFilter.Info); } }; warningBtn.OnToggled += x => { if (x) { SetFilter(filter | EntryFilter.Warning); } else { SetFilter(filter & ~EntryFilter.Warning); } }; errorBtn.OnToggled += x => { if (x) { SetFilter(filter | EntryFilter.Error); } else { SetFilter(filter & ~EntryFilter.Error); } }; detailsBtn.OnToggled += ToggleDetailsPanel; clearBtn.OnClick += ClearLog; clearOnPlayBtn.OnToggled += ToggleClearOnPlay; GUILayoutX mainLayout = layout.AddLayoutX(); listView = new GUIListView <ConsoleGUIEntry, ConsoleEntryData>(Width, ListHeight, ENTRY_HEIGHT, mainLayout); detailsSeparator = new GUITexture(Builtin.WhiteTexture, GUIOption.FixedWidth(SEPARATOR_WIDTH)); detailsArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow); mainLayout.AddElement(detailsSeparator); mainLayout.AddElement(detailsArea); detailsSeparator.Active = false; detailsArea.Active = false; detailsSeparator.SetTint(SEPARATOR_COLOR); Refresh(); Debug.OnAdded += OnEntryAdded; }
private void OnInitialize() { GUILabel title = new GUILabel(new LocEdString("Banshee Engine v0.4"), 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 Lesser General Public License V3"), EditorStyles.LabelCentered); GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2015 Marko Pintera. All rights reserved."), EditorStyles.LabelCentered); GUILabel authorLabel = new GUILabel(new LocEdString("Banshee was created, and is being actively developed by Marko Pintera.")); 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"), 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); contactFoldout.AcceptsKeyFocus = false; thirdPartyFoldout.AcceptsKeyFocus = false; noticesFoldout.AcceptsKeyFocus = false; collaboratorsFoldout.AcceptsKeyFocus = false; 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(); contactLayout.AddSpace(15); GUILayout authorLayout = contactLayout.AddLayoutX(); authorLayout.AddFlexibleSpace(); authorLayout.AddElement(authorLabel); authorLayout.AddFlexibleSpace(); contactLayout.AddSpace(15); 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"); CreateThirdPartyGUI(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/"); CreateThirdPartyGUI(thirdPartyLayout, "FreeType", "http://www.freetype.org/"); CreateThirdPartyGUI(thirdPartyLayout, "Mono", "http://www.mono-project.com/"); CreateThirdPartyGUI(thirdPartyLayout, "NVIDIA Texture Tools", "https://github.com/castano/nvidia-texture-tools"); CreateThirdPartyGUI(thirdPartyLayout, "libFLAC", "https://xiph.org/flac/"); CreateThirdPartyGUI(thirdPartyLayout, "libOgg", "https://www.xiph.org/ogg/"); CreateThirdPartyGUI(thirdPartyLayout, "libVorbis", "http://www.vorbis.com/"); CreateThirdPartyGUI(thirdPartyLayout, "OpenAL Soft", "http://kcat.strangesoft.net/openal.html"); 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"); CreateCollaboratorGUI(collaboratorsLayout, "Marco Bellan", "Bugfixes, editor enhancements"); 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"); }; }
private void OnInitialize() { guiOK = new GUIButton(new LocEdString("OK")); guiCancel = new GUIButton(new LocEdString("Cancel")); guiOK.OnClick += OnOK; guiCancel.OnClick += OnCancel; GUILayout mainVertLayout = GUI.AddLayoutY(); mainVertLayout.AddSpace(10); GUILayout editorHorzLayout = mainVertLayout.AddLayoutX(); editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING); GUIPanel gradientEditorPanel = editorHorzLayout.AddPanel(); editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING); mainVertLayout.AddSpace(15); GUILayout buttonHorzLayout = mainVertLayout.AddLayoutX(); buttonHorzLayout.AddFlexibleSpace(); buttonHorzLayout.AddElement(guiOK); buttonHorzLayout.AddSpace(10); buttonHorzLayout.AddElement(guiCancel); buttonHorzLayout.AddFlexibleSpace(); mainVertLayout.AddFlexibleSpace(); editorPanel = gradientEditorPanel.AddPanel(0); GUIPanel editorOverlay = gradientEditorPanel.AddPanel(-1); overlayCanvas = new GUICanvas(); editorOverlay.AddElement(overlayCanvas); GUILayout editorVertLayout = editorPanel.AddLayoutY(); GUILayout guiGradientLayout = editorVertLayout.AddLayoutX(); guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2); texture = Texture.Create2D(TEX_WIDTH, TEX_HEIGHT); spriteTexture = new SpriteTexture(texture); guiGradientTexture = new GUITexture(spriteTexture, GUITextureScaleMode.StretchToFit); guiGradientTexture.SetHeight(30); UpdateTexture(); guiGradientLayout.AddElement(guiGradientTexture); guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2); editorVertLayout.AddSpace(10); editor = new GradientKeyEditor(editorVertLayout, gradient.GetKeys(), Width - EDITOR_HORZ_PADDING * 2, 20); editor.OnGradientModified += colorGradient => { gradient = colorGradient; UpdateTexture(); UpdateKeyLines(); }; editorVertLayout.AddFlexibleSpace(); GUITexture containerBg = new GUITexture(null, EditorStylesInternal.ContainerBg); Rect2I containerBounds = editor.GetBounds(GUI); containerBounds.x -= 2; containerBounds.y -= 2; containerBounds.width += 4; containerBounds.height += 6; containerBg.Bounds = containerBounds; GUIPanel editorUnderlay = GUI.AddPanel(1); editorUnderlay.AddElement(containerBg); UpdateKeyLines(); EditorInput.OnPointerPressed += OnPointerPressed; EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked; EditorInput.OnPointerMoved += OnPointerMoved; EditorInput.OnPointerReleased += OnPointerReleased; EditorInput.OnButtonUp += OnButtonUp; }
/// <summary> /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before /// use. /// </summary> /// <param name="parent">Libary window that this drop down window is a part of.</param> internal void Initialize(LibraryWindow parent) { this.parent = parent; GUIToggleGroup group = new GUIToggleGroup(); GUIToggle list16 = new GUIToggle(new LocEdString("16"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); GUIToggle grid32 = new GUIToggle(new LocEdString("32"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); GUIToggle grid48 = new GUIToggle(new LocEdString("48"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); GUIToggle grid64 = new GUIToggle(new LocEdString("64"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); ProjectViewType activeType = parent.ViewType; switch (activeType) { case ProjectViewType.List16: list16.Value = true; break; case ProjectViewType.Grid32: grid32.Value = true; break; case ProjectViewType.Grid48: grid48.Value = true; break; case ProjectViewType.Grid64: grid64.Value = true; break; } list16.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.List16); } }; grid32.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.Grid32); } }; grid48.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.Grid48); } }; grid64.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.Grid64); } }; GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX contentLayout = vertLayout.AddLayoutX(); contentLayout.AddFlexibleSpace(); contentLayout.AddElement(list16); contentLayout.AddElement(grid32); contentLayout.AddElement(grid48); contentLayout.AddElement(grid64); contentLayout.AddFlexibleSpace(); vertLayout.AddFlexibleSpace(); }
private void OnInitialize() { EditorApplication.OnProjectSave += SaveSettings; SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>(); if (sceneWindow != null) { viewSettings = sceneWindow.Camera.ViewSettings; moveSettings = sceneWindow.Camera.MoveSettings; renderSettings = sceneWindow.Camera.RenderSettings; gizmoSettings = sceneWindow.GizmoDrawSettings; } else { viewSettings = ProjectSettings.GetObject <SceneCameraViewSettings>(SceneCamera.ViewSettingsKey); moveSettings = ProjectSettings.GetObject <SceneCameraMoveSettings>(SceneCamera.MoveSettingsKey); renderSettings = ProjectSettings.GetObject <RenderSettings>(SceneCamera.RenderSettingsKey); if (ProjectSettings.HasKey(SceneWindow.GizmoDrawSettingsKey)) { gizmoSettings = ProjectSettings.GetObject <GizmoDrawSettings>(SceneWindow.GizmoDrawSettingsKey); } else { gizmoSettings = GizmoDrawSettings.Default(); } } expandStates = ProjectSettings.GetObject <SerializableProperties>(ExpandStatesKey); InspectableContext inspectableContext = new InspectableContext(expandStates); GUILayout mainLayout = GUI.AddLayoutY(); GUIScrollArea scrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow); mainLayout.AddElement(scrollArea); GUILayoutX horzPadLayout = scrollArea.Layout.AddLayoutX(GUIOption.FlexibleWidth(100, 400)); horzPadLayout.AddSpace(5); GUILayout vertLayout = horzPadLayout.AddLayoutY(); horzPadLayout.AddSpace(5); vertLayout.AddSpace(5); vertLayout.AddElement(new GUILabel(new LocEdString("View Settings"), EditorStyles.LabelBold)); GUILayoutY viewSettingsLayout = vertLayout.AddLayoutY(); vertLayout.AddSpace(10); vertLayout.AddElement(new GUILabel(new LocEdString("Gizmo Settings"), EditorStyles.LabelBold)); GUILayoutY gizmoSettingsLayout = vertLayout.AddLayoutY(); vertLayout.AddSpace(10); vertLayout.AddElement(new GUILabel(new LocEdString("Move Settings"), EditorStyles.LabelBold)); GUILayoutY moveSettingsLayout = vertLayout.AddLayoutY(); vertLayout.AddSpace(10); vertLayout.AddElement(new GUILabel(new LocEdString("Render Settings"), EditorStyles.LabelBold)); GUILayoutY renderSettingsLayout = vertLayout.AddLayoutY(); guiViewSettings = new InspectorFieldDrawer(inspectableContext, viewSettingsLayout); guiGizmoSettings = new InspectorFieldDrawer(inspectableContext, gizmoSettingsLayout); guiMovementSettings = new InspectorFieldDrawer(inspectableContext, moveSettingsLayout); guiRenderSettings = new InspectorFieldDrawer(inspectableContext, renderSettingsLayout); objGizmoSettings = gizmoSettings; guiViewSettings.AddDefault(viewSettings); guiGizmoSettings.AddDefault(objGizmoSettings); guiMovementSettings.AddDefault(moveSettings); guiRenderSettings.AddDefault(renderSettings); mainLayout.AddSpace(5); GUILayout buttonCenterLayout = mainLayout.AddLayoutX(); mainLayout.AddSpace(5); GUIButton resetToDefaultBtn = new GUIButton(new LocEdString("Reset to defaults")); resetToDefaultBtn.OnClick += () => ConfirmResetToDefault(ResetToDefault, null); buttonCenterLayout.AddFlexibleSpace(); buttonCenterLayout.AddElement(resetToDefaultBtn); buttonCenterLayout.AddFlexibleSpace(); }
private void OnInitialize() { GUILabel title = new GUILabel(new LocEdString("Banshee Editor " + EngineVersion.GetFullVersionString()), EditorStyles.TitleLabel); GUILabel subTitle = new GUILabel(new LocEdString("A modern open-source game development toolkit"), EditorStyles.LabelCentered); GUILabel bsfVersion = new GUILabel(new LocEdString("Powered by bs::framework " + FrameworkVersion.GetFullVersionString()), EditorStyles.LabelCentered); GUILabel license = new GUILabel(new LocEdString( "This program is licensed under the GNU Lesser General Public License V3 or later"), EditorStyles.LabelCentered); GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2014 - " + EngineVersion.GetCurrentReleaseYearNumber() + " Jonathan Harrison and contributors. All rights reserved."), EditorStyles.LabelCentered); GUILabel editorContributorsLabel = new GUILabel(new LocEdString("Editor contributors"), EditorStyles.TitleLabel); GUILabel frameworkContributorsLabel = new GUILabel(new LocEdString("Framework contributors"), EditorStyles.TitleLabel); GUILabel engineLabel = new GUILabel(new LocEdString("Editor and engine"), EditorStyles.TitleLabel); GUILabel frameworkLabel = new GUILabel(new LocEdString("Framework"), EditorStyles.TitleLabel); GUILabel authorLabel = new GUILabel(new LocEdString("Banshee was created, and is being actively developed by Jonathan Harrison.")); 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")); GUIButton patreonBtn = new GUIButton(new LocEdString("Support us on Patreon!"), GUIOption.FixedWidth(210)); GUIButton paypalBtn = new GUIButton(new LocEdString("Donate via PayPal!"), GUIOption.FixedWidth(210)); GUIScrollArea scrollArea = new GUIScrollArea(); GUIToggleGroup foldoutGroup = new GUIToggleGroup(true); GUIToggle contactFoldout = new GUIToggle(new LocEdString("Main author"), 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 contributorsFoldout = new GUIToggle(new LocEdString("Contributors"), foldoutGroup, EditorStyles.Foldout); GUIToggle socialFoldout = new GUIToggle(new LocEdString("Social"), foldoutGroup, EditorStyles.Foldout); contactFoldout.AcceptsKeyFocus = false; thirdPartyFoldout.AcceptsKeyFocus = false; noticesFoldout.AcceptsKeyFocus = false; contributorsFoldout.AcceptsKeyFocus = false; socialFoldout.AcceptsKeyFocus = false; GUILabel freeTypeNotice = new GUILabel(new LocEdString( "Portions of this software are copyright (C) 2019 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 2019 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)); string[ , ] contributorListEditor = new string[, ] { { "Danijel Ribic", "Logo, UI icons, 3D models & textures" }, { "Marco Bellan", "Bugfixes, editor enhancements" }, { "Robert Campbell", "Editor enhancements" }, { "James Mitchell", "Build enhancements" }, { "Patrick Recko", "Minor enhancements" } }; string[] contributorListFramework = new string[] { "Marc Legendre", "Florian Will", "Marco Bellan", "Artur K. (@nemerle)", "Michael Jones", "Connor Fitzgerald", "Paolo Paoletto", "Patrick Recko", "Guillaume Meunier", "Andre Taulien", "James Mitchell", "and others..." }; GUILayoutY mainLayout = GUI.AddLayoutY(); mainLayout.AddSpace(10); mainLayout.AddElement(title); mainLayout.AddElement(subTitle); mainLayout.AddSpace(10); mainLayout.AddElement(bsfVersion); mainLayout.AddSpace(10); mainLayout.AddElement(license); mainLayout.AddSpace(5); mainLayout.AddElement(copyright); mainLayout.AddSpace(10); GUILayoutX donateButtonLayoutX = mainLayout.AddLayoutX(); donateButtonLayoutX.AddSpace(10); donateButtonLayoutX.AddElement(patreonBtn); donateButtonLayoutX.AddSpace(10); donateButtonLayoutX.AddElement(paypalBtn); donateButtonLayoutX.AddSpace(10); mainLayout.AddSpace(10); mainLayout.AddElement(scrollArea); scrollArea.Layout.AddElement(contactFoldout); GUILayoutY contactLayout = scrollArea.Layout.AddLayoutY(); contactLayout.AddSpace(15); GUILayout authorLayout = contactLayout.AddLayoutX(); authorLayout.AddFlexibleSpace(); authorLayout.AddElement(authorLabel); authorLayout.AddFlexibleSpace(); contactLayout.AddSpace(15); 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); scrollArea.Layout.AddSpace(5); scrollArea.Layout.AddElement(thirdPartyFoldout); GUILayoutY thirdPartyLayout = scrollArea.Layout.AddLayoutY(); thirdPartyLayout.AddSpace(5); CreateNameURLBtnPair(thirdPartyLayout, "Autodesk FBX SDK", "https://www.autodesk.com/products/fbx/overview", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "FreeType", "http://www.freetype.org/", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "Mono", "http://www.mono-project.com/", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "NVIDIA Texture Tools", "https://github.com/castano/nvidia-texture-tools", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "libFLAC", "https://xiph.org/flac/", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "libOgg", "https://www.xiph.org/ogg/", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "libVorbis", "http://www.vorbis.com/", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "OpenAL Soft", "http://kcat.strangesoft.net/openal.html", "Website"); CreateNameURLBtnPair(thirdPartyLayout, "NVIDIA PhysX", "https://developer.nvidia.com/physx-sdk", "Website"); scrollArea.Layout.AddSpace(5); scrollArea.Layout.AddElement(noticesFoldout); GUILayout noticesLayout = scrollArea.Layout.AddLayoutY(); noticesLayout.AddSpace(5); noticesLayout.AddElement(freeTypeNotice); noticesLayout.AddSpace(10); noticesLayout.AddElement(fbxSdkNotice); scrollArea.Layout.AddSpace(5); scrollArea.Layout.AddElement(contributorsFoldout); GUILayoutY contributorsLayout = scrollArea.Layout.AddLayoutY(); contributorsLayout.AddSpace(5); contributorsLayout.AddElement(editorContributorsLabel); contributorsLayout.AddSpace(5); for (int i = 0; i < contributorListEditor.Length / 2; i++) { CreateEditorContributorGUI(contributorsLayout, contributorListEditor[i, 0], contributorListEditor[i, 1]); contributorsLayout.AddSpace(5); } contributorsLayout.AddSpace(10); contributorsLayout.AddElement(frameworkContributorsLabel); contributorsLayout.AddSpace(5); for (int i = 0; i < contributorListFramework.Length; i++) { CreateFrameworkContributorGUI(contributorsLayout, contributorListFramework[i]); contributorsLayout.AddSpace(5); } scrollArea.Layout.AddSpace(5); scrollArea.Layout.AddElement(socialFoldout); GUILayoutY socialLayout = scrollArea.Layout.AddLayoutY(); socialLayout.AddSpace(10); CreateNameURLBtnPair(socialLayout, "Discord", "https://discord.gg/8Xyf5gF", "Enter"); socialLayout.AddSpace(10); socialLayout.AddElement(engineLabel); socialLayout.AddSpace(5); CreateNameURLBtnPair(socialLayout, "Website", "http://www.banshee3d.com", "Enter"); CreateNameURLBtnPair(socialLayout, "Repository", "https://github.com/BearishSun/BansheeEngine", "Enter"); CreateNameURLBtnPair(socialLayout, "Forums", "https://forum.banshee3d.com", "Enter"); CreateNameURLBtnPair(socialLayout, "Twitter", "https://twitter.com/Banshee3D", "Enter"); CreateNameURLBtnPair(socialLayout, "Facebook", "https://www.facebook.com/Banshee3D", "Enter"); socialLayout.AddSpace(10); socialLayout.AddElement(frameworkLabel); socialLayout.AddSpace(5); CreateNameURLBtnPair(socialLayout, "Website", "http://www.bsframework.io", "Enter"); CreateNameURLBtnPair(socialLayout, "Repository", "https://github.com/GameFoundry/bsf", "Enter"); CreateNameURLBtnPair(socialLayout, "Forums", "https://discourse.bsframework.io/", "Enter"); CreateNameURLBtnPair(socialLayout, "Twitter", "https://twitter.com/thebsframework", "Enter"); CreateNameURLBtnPair(socialLayout, "Facebook", "https://www.facebook.com/bsframework", "Enter"); 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; contributorsLayout.Active = false; contributorsFoldout.OnToggled += x => contributorsLayout.Active = x; socialLayout.Active = false; socialFoldout.OnToggled += x => socialLayout.Active = x; emailLabel.Text = "*****@*****.**"; linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("https://www.linkedin.com/in/markopintera"); }; patreonBtn.OnClick += () => { System.Diagnostics.Process.Start("https://www.patreon.com/bsf"); }; paypalBtn.OnClick += () => { System.Diagnostics.Process.Start("https://www.paypal.me/MarkoPintera/10"); }; }
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(); GUIPanel sceneAxesPanel = mainPanel.AddPanel(-1); sceneAxesGUI = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective); toggleProfilerOverlayKey = new VirtualButton(ToggleProfilerOverlayBinding); viewToolKey = new VirtualButton(ViewToolBinding); moveToolKey = new VirtualButton(MoveToolBinding); rotateToolKey = new VirtualButton(RotateToolBinding); scaleToolKey = new VirtualButton(ScaleToolBinding); duplicateKey = new VirtualButton(DuplicateBinding); deleteKey = new VirtualButton(DeleteBinding); frameKey = new VirtualButton(FrameBinding); UpdateRenderTexture(Width, Height - HeaderHeight); UpdateProfilerOverlay(); }
private void OnInitialize() { Title = "Project Manager"; Width = 500; Height = 290; GUILayout vertLayout = GUI.AddLayoutY(); vertLayout.AddSpace(5); GUILayout firstRow = vertLayout.AddLayoutX(); vertLayout.AddFlexibleSpace(); GUILayout secondRow = vertLayout.AddLayoutX(); vertLayout.AddSpace(5); GUILayout thirdRow = vertLayout.AddLayoutX(); vertLayout.AddFlexibleSpace(); GUILayout fourthRow = vertLayout.AddLayoutX(); vertLayout.AddSpace(5); projectInputBox = new GUITextField(new LocEdString("Project path"), 70, false, "", GUIOption.FixedWidth(398)); projectInputBox.Value = EditorSettings.LastOpenProject; GUIButton openBtn = new GUIButton(new LocEdString("Open"), GUIOption.FixedWidth(75)); openBtn.OnClick += OpenProject; firstRow.AddSpace(5); firstRow.AddElement(projectInputBox); firstRow.AddSpace(15); firstRow.AddElement(openBtn); firstRow.AddSpace(5); GUILabel recentProjectsLabel = new GUILabel(new LocEdString("Recent projects:")); secondRow.AddSpace(5); secondRow.AddElement(recentProjectsLabel); secondRow.AddFlexibleSpace(); GUIButton browseBtn = new GUIButton(new LocEdString("Browse"), GUIOption.FixedWidth(75)); browseBtn.OnClick += BrowseClicked; secondRow.AddElement(browseBtn); secondRow.AddSpace(5); thirdRow.AddSpace(5); GUIPanel recentProjectsPanel = thirdRow.AddPanel(); thirdRow.AddSpace(15); GUILayoutY thirdRowVertical = thirdRow.AddLayoutY(); GUIButton createBtn = new GUIButton(new LocEdString("Create new"), GUIOption.FixedWidth(75)); createBtn.OnClick += CreateClicked; thirdRowVertical.AddElement(createBtn); thirdRowVertical.AddFlexibleSpace(); thirdRow.AddSpace(5); recentProjectsArea = new GUIScrollArea(GUIOption.FixedWidth(385), GUIOption.FixedHeight(170)); GUILayoutX recentProjectsLayout = recentProjectsPanel.AddLayoutX(); recentProjectsLayout.AddSpace(10); GUILayoutY recentProjectsPanelY = recentProjectsLayout.AddLayoutY(); recentProjectsPanelY.AddSpace(5); recentProjectsPanelY.AddElement(recentProjectsArea); recentProjectsPanelY.AddSpace(5); recentProjectsLayout.AddFlexibleSpace(); GUIPanel scrollAreaBgPanel = recentProjectsPanel.AddPanel(1); GUITexture scrollAreaBgTex = new GUITexture(null, true, EditorStylesInternal.ScrollAreaBg); scrollAreaBgPanel.AddElement(scrollAreaBgTex); autoLoadToggle = new GUIToggle(""); autoLoadToggle.Value = EditorSettings.AutoLoadLastProject; GUILabel autoLoadLabel = new GUILabel(new LocEdString("Automatically load last open project")); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"), GUIOption.FixedWidth(75)); cancelBtn.OnClick += CancelClicked; fourthRow.AddSpace(5); fourthRow.AddElement(autoLoadToggle); fourthRow.AddElement(autoLoadLabel); fourthRow.AddFlexibleSpace(); fourthRow.AddElement(cancelBtn); fourthRow.AddSpace(5); RefreshRecentProjects(); }
private void OnInitialize() { GUIToggle projectFoldout = new GUIToggle(new LocEdString("Project"), EditorStyles.Foldout); GUIToggle editorFoldout = new GUIToggle(new LocEdString("Editor"), EditorStyles.Foldout); defaultHandleSizeField = new GUIFloatField(new LocEdString("Handle size"), 200); defaultHandleSizeField.OnChanged += (x) => { EditorSettings.DefaultHandleSize = x; }; autoLoadLastProjectField = new GUIToggleField(new LocEdString("Automatically load last project"), 200); autoLoadLastProjectField.OnChanged += (x) => { EditorSettings.AutoLoadLastProject = x; }; CodeEditorType[] availableEditors = CodeEditor.AvailableEditors; Array.Resize(ref availableEditors, availableEditors.Length + 1); availableEditors[availableEditors.Length - 1] = CodeEditorType.None; string[] availableEditorNames = new string[availableEditors.Length]; for (int i = 0; i < availableEditors.Length; i++) { availableEditorNames[i] = Enum.GetName(typeof(CodeEditorType), availableEditors[i]); } codeEditorField = new GUIListBoxField(availableEditorNames, new LocEdString("Code editor"), 200); codeEditorField.OnSelectionChanged += x => { EditorSettings.SetInt(ActiveCodeEditorKey, (int)availableEditors[x]); CodeEditor.ActiveEditor = availableEditors[x]; }; fpsLimitField = new GUIIntField(new LocEdString("FPS limit"), 200); fpsLimitField.OnConfirmed += () => EditorSettings.FPSLimit = fpsLimitField.Value; fpsLimitField.OnFocusLost += () => EditorSettings.FPSLimit = fpsLimitField.Value; mouseSensitivityField = new GUISliderField(0.2f, 2.0f, new LocEdString("Mouse sensitivity")); mouseSensitivityField.OnChanged += (x) => EditorSettings.MouseSensitivity = x; GUILayout mainLayout = GUI.AddLayoutY(); mainLayout.AddElement(projectFoldout); GUILayout projectLayoutOuterY = mainLayout.AddLayoutY(); projectLayoutOuterY.AddSpace(5); GUILayout projectLayoutOuterX = projectLayoutOuterY.AddLayoutX(); projectLayoutOuterX.AddSpace(5); GUILayout projectLayout = projectLayoutOuterX.AddLayoutY(); projectLayoutOuterX.AddSpace(5); projectLayoutOuterY.AddSpace(5); mainLayout.AddElement(editorFoldout); GUILayout editorLayoutOuterY = mainLayout.AddLayoutY(); editorLayoutOuterY.AddSpace(5); GUILayout editorLayoutOuterX = editorLayoutOuterY.AddLayoutX(); editorLayoutOuterX.AddSpace(5); GUILayout editorLayout = editorLayoutOuterX.AddLayoutY(); editorLayoutOuterX.AddSpace(5); editorLayoutOuterY.AddSpace(5); mainLayout.AddFlexibleSpace(); editorLayout.AddElement(defaultHandleSizeField); editorLayout.AddElement(autoLoadLastProjectField); editorLayout.AddElement(codeEditorField); editorLayout.AddElement(fpsLimitField); editorLayout.AddElement(mouseSensitivityField); projectFoldout.Value = true; editorFoldout.Value = true; projectFoldout.OnToggled += (x) => projectLayout.Active = x; editorFoldout.OnToggled += (x) => editorLayout.Active = x; }
/// <summary> /// Creates all of the GUI elements required for the specified type of dialog box. /// </summary> private void SetupGUI() { messageLabel = new GUILabel("", EditorStyles.MultiLineLabel, GUIOption.FixedWidth(260), GUIOption.FlexibleHeight(0, 600)); GUILayoutY layoutY = GUI.AddLayoutY(); layoutY.AddSpace(10); GUILayoutX messageLayout = layoutY.AddLayoutX(); messageLayout.AddFlexibleSpace(); messageLayout.AddElement(messageLabel); messageLayout.AddFlexibleSpace(); layoutY.AddSpace(10); GUILayoutX btnLayout = layoutY.AddLayoutX(); btnLayout.AddFlexibleSpace(); switch (type) { case Type.OK: { GUIButton okBtn = new GUIButton(new LocEdString("OK")); okBtn.OnClick += () => ButtonClicked(ResultType.OK); btnLayout.AddElement(okBtn); } break; case Type.OKCancel: { GUIButton okBtn = new GUIButton(new LocEdString("OK")); okBtn.OnClick += () => ButtonClicked(ResultType.OK); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); btnLayout.AddElement(okBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); } break; case Type.RetryAbortIgnore: { GUIButton retryBtn = new GUIButton(new LocEdString("Retry")); retryBtn.OnClick += () => ButtonClicked(ResultType.Retry); GUIButton abortBtn = new GUIButton(new LocEdString("Abort")); abortBtn.OnClick += () => ButtonClicked(ResultType.Abort); GUIButton ignoreBtn = new GUIButton(new LocEdString("Ignore")); ignoreBtn.OnClick += () => ButtonClicked(ResultType.Ignore); btnLayout.AddElement(retryBtn); btnLayout.AddSpace(20); btnLayout.AddElement(abortBtn); btnLayout.AddSpace(20); btnLayout.AddElement(ignoreBtn); } break; case Type.RetryCancel: { GUIButton retryBtn = new GUIButton(new LocEdString("Retry")); retryBtn.OnClick += () => ButtonClicked(ResultType.Retry); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); btnLayout.AddElement(retryBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); } break; case Type.TryCancelContinue: { GUIButton tryBtn = new GUIButton(new LocEdString("Try")); tryBtn.OnClick += () => ButtonClicked(ResultType.Try); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); GUIButton continueBtn = new GUIButton(new LocEdString("Continue")); continueBtn.OnClick += () => ButtonClicked(ResultType.Continue); btnLayout.AddElement(tryBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); btnLayout.AddSpace(20); btnLayout.AddElement(continueBtn); } break; case Type.YesNo: { GUIButton yesBtn = new GUIButton(new LocEdString("Yes")); yesBtn.OnClick += () => ButtonClicked(ResultType.Yes); GUIButton noBtn = new GUIButton(new LocEdString("No")); noBtn.OnClick += () => ButtonClicked(ResultType.No); btnLayout.AddElement(yesBtn); btnLayout.AddSpace(20); btnLayout.AddElement(noBtn); } break; case Type.YesNoCancel: { GUIButton yesBtn = new GUIButton(new LocEdString("Yes")); yesBtn.OnClick += () => ButtonClicked(ResultType.Yes); GUIButton noBtn = new GUIButton(new LocEdString("No")); noBtn.OnClick += () => ButtonClicked(ResultType.No); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); btnLayout.AddElement(yesBtn); btnLayout.AddSpace(20); btnLayout.AddElement(noBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); } break; } btnLayout.AddFlexibleSpace(); layoutY.AddFlexibleSpace(); }
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 GUIButton(playIcon); recordButton = new GUIButton(recordIcon); prevFrameButton = new GUIButton(prevFrameIcon); frameInputField = new GUIIntField(); nextFrameButton = new GUIButton(nextFrameIcon); addKeyframeButton = new GUIButton(addKeyframeIcon); addEventButton = new GUIButton(addEventIcon); optionsButton = new GUIButton(optionsIcon); playButton.OnClick += () => { // TODO // - Record current state of the scene object hierarchy // - Evaluate all curves manually and update them // - On end, restore original values of the scene object hierarchy }; recordButton.OnClick += () => { // TODO // - Every frame read back current values of all the current curve's properties and assign it to the current frame }; prevFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx - 1); }; frameInputField.OnChanged += SetCurrentFrame; nextFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx + 1); }; addKeyframeButton.OnClick += () => { guiCurveEditor.AddKeyFrameAtMarker(); }; addEventButton.OnClick += () => { 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)) { 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(); 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 { openPropertyWindow(); } } }; delPropertyBtn.OnClick += () => { if (clipInfo.clip == null) { return; } 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(); } }); } }; 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 += EditorApplication.SetProjectDirty; guiCurveEditor.Redraw(); horzScrollBar.SetWidth(curveEditorSize.x); vertScrollBar.SetHeight(curveEditorSize.y); UpdateScrollBarSize(); }
/// <summary> /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before /// use. /// </summary> /// <param name="animEvent">Event whose properties to edit.</param> /// <param name="componentNames">List of component names that the user can select from.</param> /// <param name="updateCallback">Callback triggered when event values change.</param> internal void Initialize(AnimationEvent animEvent, string[] componentNames, Action updateCallback) { int selectedIndex = -1; string methodName = ""; if (!string.IsNullOrEmpty(animEvent.Name)) { string[] nameEntries = animEvent.Name.Split('/'); if (nameEntries.Length > 1) { string typeName = nameEntries[0]; for (int i = 0; i < componentNames.Length; i++) { if (componentNames[i] == typeName) { selectedIndex = i; break; } } methodName = nameEntries[nameEntries.Length - 1]; } } GUIFloatField timeField = new GUIFloatField(new LocEdString("Time"), 40, ""); timeField.Value = animEvent.Time; timeField.OnChanged += x => { animEvent.Time = x; updateCallback(); }; // TODO UNDOREDO GUIListBoxField componentField = new GUIListBoxField(componentNames, new LocEdString("Component"), 40); if (selectedIndex != -1) { componentField.Index = selectedIndex; } componentField.OnSelectionChanged += x => { string compName = ""; if (x != -1) { compName = componentNames[x] + "/"; } animEvent.Name = compName + x; updateCallback(); };// TODO UNDOREDO GUITextField methodField = new GUITextField(new LocEdString("Method"), 40, false, "", GUIOption.FixedWidth(190)); methodField.Value = methodName; methodField.OnChanged += x => { string compName = ""; if (componentField.Index != -1) { compName = componentNames[componentField.Index] + "/"; } animEvent.Name = compName + x; updateCallback(); }; // TODO UNDOREDO GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX horzLayout = vertLayout.AddLayoutX(); horzLayout.AddFlexibleSpace(); GUILayout contentLayout = horzLayout.AddLayoutY(); GUILayout timeLayout = contentLayout.AddLayoutX(); timeLayout.AddSpace(5); timeLayout.AddElement(timeField); timeLayout.AddFlexibleSpace(); GUILayout componentLayout = contentLayout.AddLayoutX(); componentLayout.AddSpace(5); componentLayout.AddElement(componentField); componentLayout.AddFlexibleSpace(); GUILayout methodLayout = contentLayout.AddLayoutX(); methodLayout.AddSpace(5); methodLayout.AddElement(methodField); methodLayout.AddFlexibleSpace(); horzLayout.AddFlexibleSpace(); vertLayout.AddFlexibleSpace(); }