/// <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(); }
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); 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"); }; }
/// <summary> /// Creates a set of objects in which each object represents a GUI for a material parameter. /// </summary> /// <param name="mat">Material for whose parameters to create GUI for.</param> /// <param name="path">Path to the material field in the parent object.</param> /// <param name="component">Optional component the material is part of (if any).</param> /// <param name="layout">Layout to add the parameter GUI elements to.</param> /// <returns>A material parameter GUI object for each supported material parameter.</returns> internal static MaterialParamGUI[] CreateMaterialGUI(Material mat, string path, Component component, GUILayout layout) { Shader shader = mat.Shader.Value; if (shader == null) { return(new MaterialParamGUI[0]); } List <MaterialParamGUI> guiParams = new List <MaterialParamGUI>(); ShaderParameter[] shaderParams = shader.Parameters; foreach (var param in shaderParams) { if (param.flags.HasFlag(ShaderParameterFlag.Internal) || param.flags.HasFlag(ShaderParameterFlag.HideInInspector)) { continue; } switch (param.type) { case ShaderParameterType.Float: layout.AddSpace(5); guiParams.Add(new MaterialParamFloatGUI(param, path, component, mat, layout)); break; case ShaderParameterType.Vector2: layout.AddSpace(5); guiParams.Add(new MaterialParamVec2GUI(param, path, component, mat, layout)); break; case ShaderParameterType.Vector3: layout.AddSpace(5); guiParams.Add(new MaterialParamVec3GUI(param, path, component, mat, layout)); break; case ShaderParameterType.Vector4: layout.AddSpace(5); guiParams.Add(new MaterialParamVec4GUI(param, path, component, mat, layout)); break; case ShaderParameterType.Matrix3: layout.AddSpace(5); guiParams.Add(new MaterialParamMat3GUI(param, path, component, mat, layout)); break; case ShaderParameterType.Matrix4: layout.AddSpace(5); guiParams.Add(new MaterialParamMat4GUI(param, path, component, mat, layout)); break; case ShaderParameterType.Color: bool hdr = param.flags.HasFlag(ShaderParameterFlag.HDR); layout.AddSpace(5); guiParams.Add(new MaterialParamColorGUI(param, path, hdr, component, mat, layout)); break; case ShaderParameterType.Texture2D: case ShaderParameterType.Texture3D: case ShaderParameterType.TextureCube: layout.AddSpace(5); guiParams.Add(new MaterialParamTextureGUI(param, path, component, mat, layout)); break; } } return(guiParams.ToArray()); }
private void OnInitialize() { guiColor = new GUIColorField("", GUIOption.FixedWidth(100)); guiSlider2DTex = new GUITexture(null, GUIOption.FixedHeight(ColorBoxHeight), GUIOption.FixedWidth(ColorBoxWidth)); guiSliderVertTex = new GUITexture(null, GUIOption.FixedHeight(SliderSideHeight), GUIOption.FixedWidth(SliderSideWidth)); guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiColorBoxBtn = new GUIButton(colorBoxMode.ToString()); guiColorModeBtn = new GUIButton(sliderMode.ToString()); guiSliderVert = new GUISliderV(EditorStylesInternal.ColorSliderVert); guiSliderRHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSliderGHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSliderBHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSliderAHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSlider2DHandle = new GUITexture(null, EditorStylesInternal.ColorSlider2DHandle); guiLabelR = new GUILabel(new LocEdString("R")); guiLabelG = new GUILabel(new LocEdString("G")); guiLabelB = new GUILabel(new LocEdString("B")); guiLabelA = new GUILabel(new LocEdString("A")); guiInputR = new GUIIntField(); guiInputG = new GUIIntField(); guiInputB = new GUIIntField(); guiInputA = new GUIIntField(); guiOK = new GUIButton(new LocEdString("OK")); guiCancel = new GUIButton(new LocEdString("Cancel")); guiColorBoxBtn.OnClick += OnColorBoxModeChanged; guiColorModeBtn.OnClick += OnSliderModeChanged; guiSliderVert.OnChanged += OnSliderVertChanged; guiSliderRHorz.OnChanged += OnSliderRHorzChanged; guiSliderGHorz.OnChanged += OnSliderGHorzChanged; guiSliderBHorz.OnChanged += OnSliderBHorzChanged; guiSliderAHorz.OnChanged += OnSliderAHorzChanged; guiInputR.OnChanged += OnInputRChanged; guiInputG.OnChanged += OnInputGChanged; guiInputB.OnChanged += OnInputBChanged; guiInputA.OnChanged += OnInputAChanged; guiOK.OnClick += OnOK; guiCancel.OnClick += OnCancel; GUIPanel mainPanel = GUI.AddPanel(0); GUILayout v0 = mainPanel.AddLayoutY(); v0.AddSpace(5); GUILayout h0 = v0.AddLayoutX(); h0.AddSpace(10); h0.AddElement(guiColor); h0.AddFlexibleSpace(); h0.AddElement(guiColorBoxBtn); h0.AddElement(guiColorModeBtn); h0.AddSpace(10); v0.AddSpace(10); GUILayout h1 = v0.AddLayoutX(); h1.AddSpace(10); h1.AddElement(guiSlider2DTex); h1.AddFlexibleSpace(); h1.AddElement(guiSliderVertTex); h1.AddSpace(10); v0.AddSpace(10); GUILayout h2 = v0.AddLayoutX(); h2.AddSpace(10); h2.AddElement(guiLabelR); h2.AddFlexibleSpace(); h2.AddElement(guiSliderRHorzTex); h2.AddFlexibleSpace(); h2.AddElement(guiInputR); h2.AddSpace(10); v0.AddSpace(5); GUILayout h3 = v0.AddLayoutX(); h3.AddSpace(10); h3.AddElement(guiLabelG); h3.AddFlexibleSpace(); h3.AddElement(guiSliderGHorzTex); h3.AddFlexibleSpace(); h3.AddElement(guiInputG); h3.AddSpace(10); v0.AddSpace(5); GUILayout h4 = v0.AddLayoutX(); h4.AddSpace(10); h4.AddElement(guiLabelB); h4.AddFlexibleSpace(); h4.AddElement(guiSliderBHorzTex); h4.AddFlexibleSpace(); h4.AddElement(guiInputB); h4.AddSpace(10); v0.AddSpace(5); GUILayout h5 = v0.AddLayoutX(); h5.AddSpace(10); h5.AddElement(guiLabelA); h5.AddFlexibleSpace(); h5.AddElement(guiSliderAHorzTex); h5.AddFlexibleSpace(); h5.AddElement(guiInputA); h5.AddSpace(10); v0.AddSpace(10); GUILayout h6 = v0.AddLayoutX(); h6.AddFlexibleSpace(); h6.AddElement(guiOK); h6.AddSpace(10); h6.AddElement(guiCancel); h6.AddFlexibleSpace(); v0.AddSpace(5); GUIPanel overlay = GUI.AddPanel(-1); overlay.SetWidth(Width); overlay.SetHeight(Height); overlay.AddElement(guiSliderVert); overlay.AddElement(guiSliderRHorz); overlay.AddElement(guiSliderGHorz); overlay.AddElement(guiSliderBHorz); overlay.AddElement(guiSliderAHorz); overlay.AddElement(guiSlider2DHandle); colorBox = new ColorSlider2D(guiSlider2DTex, guiSlider2DHandle, ColorBoxWidth, ColorBoxHeight); sideSlider = new ColorSlider1DVert(guiSliderVertTex, guiSliderVert, SliderSideWidth, SliderSideHeight); sliderR = new ColorSlider1DHorz(guiSliderRHorzTex, guiSliderRHorz, SliderIndividualWidth, SliderIndividualHeight); sliderG = new ColorSlider1DHorz(guiSliderGHorzTex, guiSliderGHorz, SliderIndividualWidth, SliderIndividualHeight); sliderB = new ColorSlider1DHorz(guiSliderBHorzTex, guiSliderBHorz, SliderIndividualWidth, SliderIndividualHeight); sliderA = new ColorSlider1DHorz(guiSliderAHorzTex, guiSliderAHorz, SliderIndividualWidth, SliderIndividualHeight); colorBox.OnValueChanged += OnColorBoxValueChanged; Color startA = new Color(0, 0, 0, 1); Color stepA = new Color(1, 1, 1, 0); sliderA.UpdateTexture(startA, stepA, false); guiInputA.SetRange(0, 255); guiInputA.Value = 255; guiSliderAHorz.Percent = 1.0f; guiColor.Value = SelectedColor; UpdateInputBoxValues(); Update2DSliderValues(); Update1DSliderValues(); UpdateSliderMode(); Update2DSliderTextures(); Update1DSliderTextures(); }
/// <summary> /// Sets a scene object whose GUI is to be displayed in the inspector. Clears any previous contents of the window. /// </summary> /// <param name="so">Scene object to inspect.</param> private void SetObjectToInspect(SceneObject so) { if (so == null) { return; } currentType = InspectorType.SceneObject; activeSO = so; inspectorScrollArea = new GUIScrollArea(); scrollAreaHighlight = new GUITexture(Builtin.WhiteTexture); scrollAreaHighlight.SetTint(HIGHLIGHT_COLOR); scrollAreaHighlight.Active = false; GUI.AddElement(inspectorScrollArea); GUIPanel inspectorPanel = inspectorScrollArea.Layout.AddPanel(); inspectorLayout = inspectorPanel.AddLayoutY(); highlightPanel = inspectorPanel.AddPanel(-1); highlightPanel.AddElement(scrollAreaHighlight); // SceneObject fields CreateSceneObjectFields(); RefreshSceneObjectFields(true); // Components Component[] allComponents = so.GetComponents(); for (int i = 0; i < allComponents.Length; i++) { inspectorLayout.AddSpace(COMPONENT_SPACING); InspectorComponent data = new InspectorComponent(); data.instanceId = allComponents[i].InstanceId; data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout); SpriteTexture xBtnIcon = EditorBuiltin.GetEditorIcon(EditorIcon.X); data.removeBtn = new GUIButton(new GUIContent(xBtnIcon), GUIOption.FixedWidth(30)); data.title = inspectorLayout.AddLayoutX(); data.title.AddElement(data.foldout); data.title.AddElement(data.removeBtn); data.panel = inspectorLayout.AddPanel(); var persistentProperties = persistentData.GetProperties(allComponents[i].InstanceId); data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType()); data.inspector.Initialize(data.panel, allComponents[i], persistentProperties); bool isExpanded = data.inspector.Persistent.GetBool(data.instanceId + "_Expanded", true); data.foldout.Value = isExpanded; if (!isExpanded) { data.inspector.SetVisible(false); } Type curComponentType = allComponents[i].GetType(); data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded); data.removeBtn.OnClick += () => OnComponentRemoveClicked(curComponentType); inspectorComponents.Add(data); } inspectorLayout.AddFlexibleSpace(); UpdateDropAreas(); }
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(); }
/// <summary> /// Sets a resource whose GUI is to be displayed in the inspector. Clears any previous contents of the window. /// </summary> /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param> private void SetObjectToInspect(String resourcePath) { activeResourcePath = resourcePath; if (!ProjectLibrary.Exists(resourcePath)) { return; } ResourceMeta meta = ProjectLibrary.GetMeta(resourcePath); if (meta == null) { return; } Type resourceType = meta.Type; currentType = InspectorType.Resource; inspectorScrollArea = new GUIScrollArea(); GUI.AddElement(inspectorScrollArea); inspectorLayout = inspectorScrollArea.Layout; GUIPanel titlePanel = inspectorLayout.AddPanel(); titlePanel.SetHeight(RESOURCE_TITLE_HEIGHT); GUILayoutY titleLayout = titlePanel.AddLayoutY(); titleLayout.SetPosition(PADDING, PADDING); string name = Path.GetFileNameWithoutExtension(resourcePath); string type = resourceType.Name; LocString title = new LocEdString(name + " (" + type + ")"); GUILabel titleLabel = new GUILabel(title); titleLayout.AddFlexibleSpace(); GUILayoutX titleLabelLayout = titleLayout.AddLayoutX(); titleLabelLayout.AddElement(titleLabel); titleLayout.AddFlexibleSpace(); GUIPanel titleBgPanel = titlePanel.AddPanel(1); GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg); titleBgPanel.AddElement(titleBg); inspectorLayout.AddSpace(COMPONENT_SPACING); inspectorResource = new InspectorResource(); inspectorResource.panel = inspectorLayout.AddPanel(); var persistentProperties = persistentData.GetProperties(meta.UUID.ToString()); inspectorResource.inspector = InspectorUtility.GetInspector(resourceType); inspectorResource.inspector.Initialize(inspectorResource.panel, activeResourcePath, persistentProperties); inspectorLayout.AddFlexibleSpace(); }
/// <summary> /// Recreates all the GUI elements used by this inspector. /// </summary> private void BuildGUI() { if (InspectedObject != null) { Camera camera = (Camera)InspectedObject; projectionTypeField.OnSelectionChanged += x => { camera.ProjectionType = (ProjectionType)x; MarkAsModified(); ConfirmModify(); ToggleTypeSpecificFields((ProjectionType)x); }; fieldOfView.OnChanged += x => { camera.FieldOfView = (Degree)x; MarkAsModified(); }; fieldOfView.OnFocusLost += ConfirmModify; orthoHeight.OnChanged += x => { camera.OrthoHeight = x; MarkAsModified(); }; orthoHeight.OnConfirmed += ConfirmModify; orthoHeight.OnFocusLost += ConfirmModify; aspectField.OnChanged += x => { camera.AspectRatio = x; MarkAsModified(); }; aspectField.OnConfirmed += ConfirmModify; aspectField.OnFocusLost += ConfirmModify; nearPlaneField.OnChanged += x => { camera.NearClipPlane = x; MarkAsModified(); }; nearPlaneField.OnConfirmed += ConfirmModify; nearPlaneField.OnFocusLost += ConfirmModify; farPlaneField.OnChanged += x => { camera.FarClipPlane = x; MarkAsModified(); }; farPlaneField.OnConfirmed += ConfirmModify; farPlaneField.OnFocusLost += ConfirmModify; viewportXField.OnChanged += x => { Rect2 rect = camera.Viewport.Area; rect.x = x; camera.Viewport.Area = rect; MarkAsModified(); }; viewportXField.OnConfirmed += ConfirmModify; viewportXField.OnFocusLost += ConfirmModify; viewportYField.OnChanged += x => { Rect2 rect = camera.Viewport.Area; rect.y = x; camera.Viewport.Area = rect; MarkAsModified(); }; viewportYField.OnConfirmed += ConfirmModify; viewportYField.OnFocusLost += ConfirmModify; viewportWidthField.OnChanged += x => { Rect2 rect = camera.Viewport.Area; rect.width = x; camera.Viewport.Area = rect; MarkAsModified(); }; viewportWidthField.OnConfirmed += ConfirmModify; viewportWidthField.OnFocusLost += ConfirmModify; viewportHeightField.OnChanged += x => { Rect2 rect = camera.Viewport.Area; rect.height = x; camera.Viewport.Area = rect; MarkAsModified(); }; viewportHeightField.OnConfirmed += ConfirmModify; viewportHeightField.OnFocusLost += ConfirmModify; clearFlagsFields.OnSelectionChanged += x => { camera.Viewport.ClearFlags = (ClearFlags)x; MarkAsModified(); ConfirmModify(); }; clearStencilField.OnChanged += x => { camera.Viewport.ClearStencil = (ushort)x; }; clearStencilField.OnConfirmed += ConfirmModify; clearStencilField.OnFocusLost += ConfirmModify; clearDepthField.OnChanged += x => { camera.Viewport.ClearDepth = x; }; clearDepthField.OnConfirmed += ConfirmModify; clearDepthField.OnFocusLost += ConfirmModify; clearColorField.OnChanged += x => { camera.Viewport.ClearColor = x; MarkAsModified(); ConfirmModify(); }; priorityField.OnChanged += x => { camera.Priority = x; MarkAsModified(); }; priorityField.OnConfirmed += ConfirmModify; priorityField.OnFocusLost += ConfirmModify; layersField.OnSelectionChanged += x => { ulong layers = 0; bool[] states = layersField.States; for (int i = 0; i < states.Length; i++) { layers |= states[i] ? Layers.Values[i] : 0; } layersValue = layers; camera.Layers = layers; MarkAsModified(); ConfirmModify(); }; mainField.OnChanged += x => { camera.Main = x; MarkAsModified(); ConfirmModify(); }; Layout.AddElement(projectionTypeField); Layout.AddElement(fieldOfView); Layout.AddElement(orthoHeight); Layout.AddElement(aspectField); Layout.AddElement(nearPlaneField); Layout.AddElement(farPlaneField); GUILayoutX viewportTopLayout = Layout.AddLayoutX(); viewportTopLayout.AddElement(new GUILabel(new LocEdString("Viewport"), GUIOption.FixedWidth(100))); GUILayoutY viewportContentLayout = viewportTopLayout.AddLayoutY(); GUILayoutX viewportTopRow = viewportContentLayout.AddLayoutX(); viewportTopRow.AddElement(viewportXField); viewportTopRow.AddElement(viewportWidthField); GUILayoutX viewportBotRow = viewportContentLayout.AddLayoutX(); viewportBotRow.AddElement(viewportYField); viewportBotRow.AddElement(viewportHeightField); Layout.AddElement(clearFlagsFields); Layout.AddElement(clearColorField); Layout.AddElement(clearDepthField); Layout.AddElement(clearStencilField); Layout.AddElement(priorityField); Layout.AddElement(layersField); Layout.AddElement(mainField); renderSettingsFoldout.OnToggled += x => { Persistent.SetBool("renderSettings_Expanded", x); renderSettingsLayout.Active = x; }; Layout.AddElement(renderSettingsFoldout); renderSettingsLayout = Layout.AddLayoutX(); { renderSettingsLayout.AddSpace(10); GUILayoutY contentsLayout = renderSettingsLayout.AddLayoutY(); renderSettingsGUI = new RenderSettingsGUI(camera.RenderSettings, contentsLayout, Persistent); renderSettingsGUI.OnChanged += x => { camera.RenderSettings = x; MarkAsModified(); }; renderSettingsGUI.OnConfirmed += ConfirmModify; } ToggleTypeSpecificFields(camera.ProjectionType); renderSettingsLayout.Active = Persistent.GetBool("renderSettings_Expanded"); } }
/// <summary> /// Refreshes the contents of the content area. Must be called at least once after construction. /// </summary> /// <param name="viewType">Determines how to display the resource tiles.</param> /// <param name="entriesToDisplay">Project library entries to display.</param> public void Refresh(ProjectViewType viewType, LibraryEntry[] entriesToDisplay) { if (mainPanel != null) { mainPanel.Destroy(); } entries = new LibraryGUIEntry[entriesToDisplay.Length]; entryLookup.Clear(); mainPanel = parent.Layout.AddPanel(); GUIPanel contentPanel = mainPanel.AddPanel(1); overlay = mainPanel.AddPanel(0); underlay = mainPanel.AddPanel(2); renameOverlay = mainPanel.AddPanel(-1); main = contentPanel.AddLayoutY(); if (viewType == ProjectViewType.List16) { tileSize = 16; gridLayout = false; elementsPerRow = 1; } else { switch (viewType) { case ProjectViewType.Grid64: tileSize = 64; break; case ProjectViewType.Grid48: tileSize = 48; break; case ProjectViewType.Grid32: tileSize = 32; break; } gridLayout = true; Rect2I scrollBounds = parent.Bounds; int availableWidth = scrollBounds.width; int elemSize = tileSize + GRID_ENTRY_SPACING; elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize; elementsPerRow = Math.Max(elementsPerRow, 1); int numRows = MathEx.CeilToInt(entriesToDisplay.Length / (float)elementsPerRow); int neededHeight = numRows * (elemSize); bool requiresScrollbar = neededHeight > scrollBounds.height; if (requiresScrollbar) { availableWidth -= parent.ScrollBarWidth; elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize; } if (elementsPerRow > 0) { labelWidth = (availableWidth - (elementsPerRow + 1) * MIN_HORZ_SPACING) / elementsPerRow; } else { labelWidth = 0; } } if (viewType == ProjectViewType.List16) { for (int i = 0; i < entriesToDisplay.Length; i++) { LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entriesToDisplay[i], i, labelWidth); entries[i] = guiEntry; entryLookup[guiEntry.path] = guiEntry; if (i != entriesToDisplay.Length - 1) { main.AddSpace(LIST_ENTRY_SPACING); } } main.AddFlexibleSpace(); } else { main.AddSpace(GRID_ENTRY_SPACING / 2); GUILayoutX rowLayout = main.AddLayoutX(); main.AddSpace(GRID_ENTRY_SPACING); rowLayout.AddFlexibleSpace(); int elemsInRow = 0; for (int i = 0; i < entriesToDisplay.Length; i++) { if (elemsInRow == elementsPerRow && elemsInRow > 0) { rowLayout = main.AddLayoutX(); main.AddSpace(GRID_ENTRY_SPACING); rowLayout.AddFlexibleSpace(); elemsInRow = 0; } LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, entriesToDisplay[i], i, labelWidth); entries[i] = guiEntry; entryLookup[guiEntry.path] = guiEntry; rowLayout.AddFlexibleSpace(); elemsInRow++; } int extraElements = elementsPerRow - elemsInRow; for (int i = 0; i < extraElements; i++) { rowLayout.AddSpace(labelWidth); rowLayout.AddFlexibleSpace(); } main.AddFlexibleSpace(); } for (int i = 0; i < entries.Length; i++) { LibraryGUIEntry guiEntry = entries[i]; guiEntry.Initialize(); } }
/// <summary> /// (Re)creates GUI with platform-specific options. /// </summary> private void BuildPlatformOptionsGUI() { optionsScrollArea.Layout.Clear(); GUILayout layout = optionsScrollArea.Layout; PlatformInfo platformInfo = BuildManager.GetPlatformInfo(selectedPlatform); GUILabel options = new GUILabel(new LocEdString("Platform options"), EditorStyles.LabelCentered); GUIResourceField sceneField = new GUIResourceField(typeof(Prefab), new LocEdString("Startup scene")); GUIToggleField debugToggle = new GUIToggleField(new LocEdString("Debug")); GUIToggleField fullscreenField = new GUIToggleField(new LocEdString("Fullscreen")); GUIIntField widthField = new GUIIntField(new LocEdString("Window width")); GUIIntField heightField = new GUIIntField(new LocEdString("Window height")); GUITextField definesField = new GUITextField(new LocEdString("Defines")); layout.AddSpace(5); layout.AddElement(options); layout.AddSpace(5); layout.AddElement(sceneField); layout.AddElement(debugToggle); layout.AddElement(fullscreenField); layout.AddElement(widthField); layout.AddElement(heightField); layout.AddSpace(5); layout.AddElement(definesField); layout.AddSpace(5); sceneField.ValueRef = platformInfo.MainScene; debugToggle.Value = platformInfo.Debug; definesField.Value = platformInfo.Defines; fullscreenField.Value = platformInfo.Fullscreen; widthField.Value = platformInfo.WindowedWidth; heightField.Value = platformInfo.WindowedHeight; if (platformInfo.Fullscreen) { widthField.Active = false; heightField.Active = false; } sceneField.OnChanged += x => platformInfo.MainScene = x; debugToggle.OnChanged += x => platformInfo.Debug = x; definesField.OnChanged += x => platformInfo.Defines = x; fullscreenField.OnChanged += x => { widthField.Active = !x; heightField.Active = !x; platformInfo.Fullscreen = x; }; widthField.OnChanged += x => platformInfo.WindowedWidth = x; heightField.OnChanged += x => platformInfo.WindowedHeight = x; switch (platformInfo.Type) { case PlatformType.Windows: { WinPlatformInfo winPlatformInfo = (WinPlatformInfo)platformInfo; GUITextField titleField = new GUITextField(new LocEdString("Title")); layout.AddElement(titleField); layout.AddSpace(5); GUITextureField iconField = new GUITextureField(new LocEdString("Icon")); layout.AddElement(iconField); titleField.Value = winPlatformInfo.TitleText; iconField.ValueRef = winPlatformInfo.Icon; titleField.OnChanged += x => winPlatformInfo.TitleText = x; iconField.OnChanged += x => winPlatformInfo.Icon = x; } break; } }
/// <summary> /// Constructs a new set of GUI elements for inspecting the post process settings object. /// </summary> /// <param name="settings">Initial values to assign to the GUI elements.</param> /// <param name="layout">Layout to append the GUI elements to.</param> /// <param name="properties">A set of properties that are persisted by the parent inspector. Used for saving state. /// </param> public RenderSettingsGUI(RenderSettings settings, GUILayout layout, SerializableProperties properties) { this.settings = settings; this.properties = properties; // Enable HDR enableHDRField.OnChanged += x => { this.settings.EnableHDR = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableHDRField); // Enable lighting enableLightingField.OnChanged += x => { this.settings.EnableLighting = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableLightingField); // Enable indirect lighting enableIndirectLightingField.OnChanged += x => { this.settings.EnableIndirectLighting = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableIndirectLightingField); // Overlay only overlayOnlyField.OnChanged += x => { this.settings.OverlayOnly = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(overlayOnlyField); // Shadows enableShadowsField.OnChanged += x => { this.settings.EnableShadows = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableShadowsField); shadowsFoldout.AcceptsKeyFocus = false; shadowsFoldout.OnToggled += x => { properties.SetBool("shadows_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(shadowsFoldout); shadowsLayout = layout.AddLayoutX(); { shadowsLayout.AddSpace(10); GUILayoutY contentsLayout = shadowsLayout.AddLayoutY(); shadowsGUI = new ShadowSettingsGUI(settings.ShadowSettings, contentsLayout); shadowsGUI.OnChanged += x => { this.settings.ShadowSettings = x; MarkAsModified(); }; shadowsGUI.OnConfirmed += ConfirmModify; } // Auto exposure enableAutoExposureField.OnChanged += x => { this.settings.EnableAutoExposure = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableAutoExposureField); autoExposureFoldout.AcceptsKeyFocus = false; autoExposureFoldout.OnToggled += x => { properties.SetBool("autoExposure_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(autoExposureFoldout); autoExposureLayout = layout.AddLayoutX(); { autoExposureLayout.AddSpace(10); GUILayoutY contentsLayout = autoExposureLayout.AddLayoutY(); autoExposureGUI = new AutoExposureSettingsGUI(settings.AutoExposure, contentsLayout); autoExposureGUI.OnChanged += x => { this.settings.AutoExposure = x; MarkAsModified(); }; autoExposureGUI.OnConfirmed += ConfirmModify; } // Tonemapping enableToneMappingField.OnChanged += x => { this.settings.EnableTonemapping = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableToneMappingField); //// Tonemapping settings toneMappingFoldout.AcceptsKeyFocus = false; toneMappingFoldout.OnToggled += x => { properties.SetBool("toneMapping_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(toneMappingFoldout); toneMappingLayout = layout.AddLayoutX(); { toneMappingLayout.AddSpace(10); GUILayoutY contentsLayout = toneMappingLayout.AddLayoutY(); toneMappingGUI = new TonemappingSettingsGUI(settings.Tonemapping, contentsLayout); toneMappingGUI.OnChanged += x => { this.settings.Tonemapping = x; MarkAsModified(); }; toneMappingGUI.OnConfirmed += ConfirmModify; } //// White balance settings whiteBalanceFoldout.AcceptsKeyFocus = false; whiteBalanceFoldout.OnToggled += x => { properties.SetBool("whiteBalance_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(whiteBalanceFoldout); whiteBalanceLayout = layout.AddLayoutX(); { whiteBalanceLayout.AddSpace(10); GUILayoutY contentsLayout = whiteBalanceLayout.AddLayoutY(); whiteBalanceGUI = new WhiteBalanceSettingsGUI(settings.WhiteBalance, contentsLayout); whiteBalanceGUI.OnChanged += x => { this.settings.WhiteBalance = x; MarkAsModified(); }; whiteBalanceGUI.OnConfirmed += ConfirmModify; } //// Color grading settings colorGradingFoldout.AcceptsKeyFocus = false; colorGradingFoldout.OnToggled += x => { properties.SetBool("colorGrading_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(colorGradingFoldout); colorGradingLayout = layout.AddLayoutX(); { colorGradingLayout.AddSpace(10); GUILayoutY contentsLayout = colorGradingLayout.AddLayoutY(); colorGradingGUI = new ColorGradingSettingsGUI(settings.ColorGrading, contentsLayout); colorGradingGUI.OnChanged += x => { this.settings.ColorGrading = x; MarkAsModified(); }; colorGradingGUI.OnConfirmed += ConfirmModify; } // Gamma gammaField.OnChanged += x => { this.settings.Gamma = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(gammaField); // Exposure scale exposureScaleField.OnChanged += x => { this.settings.ExposureScale = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(exposureScaleField); //// Depth of field settings depthOfFieldFoldout.AcceptsKeyFocus = false; depthOfFieldFoldout.OnToggled += x => { properties.SetBool("depthOfField_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(depthOfFieldFoldout); depthOfFieldLayout = layout.AddLayoutX(); { depthOfFieldLayout.AddSpace(10); GUILayoutY contentsLayout = depthOfFieldLayout.AddLayoutY(); depthOfFieldGUI = new DepthOfFieldSettingsGUI(settings.DepthOfField, contentsLayout); depthOfFieldGUI.OnChanged += x => { this.settings.DepthOfField = x; MarkAsModified(); }; depthOfFieldGUI.OnConfirmed += ConfirmModify; } //// Ambient occlusion settings ambientOcclusionFoldout.AcceptsKeyFocus = false; ambientOcclusionFoldout.OnToggled += x => { properties.SetBool("ambientOcclusion_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(ambientOcclusionFoldout); ambientOcclusionLayout = layout.AddLayoutX(); { ambientOcclusionLayout.AddSpace(10); GUILayoutY contentsLayout = ambientOcclusionLayout.AddLayoutY(); ambientOcclusionGUI = new AmbientOcclusionSettingsGUI(settings.AmbientOcclusion, contentsLayout); ambientOcclusionGUI.OnChanged += x => { this.settings.AmbientOcclusion = x; MarkAsModified(); }; ambientOcclusionGUI.OnConfirmed += ConfirmModify; } //// Screen space reflections settings screenSpaceReflectionsFoldout.AcceptsKeyFocus = false; screenSpaceReflectionsFoldout.OnToggled += x => { properties.SetBool("screenSpaceReflections_Expanded", x); ToggleFoldoutFields(); }; layout.AddElement(screenSpaceReflectionsFoldout); screenSpaceReflectionsLayout = layout.AddLayoutX(); { screenSpaceReflectionsLayout.AddSpace(10); GUILayoutY contentsLayout = screenSpaceReflectionsLayout.AddLayoutY(); screenSpaceReflectionsGUI = new ScreenSpaceReflectionsSettingsGUI(settings.ScreenSpaceReflections, contentsLayout); screenSpaceReflectionsGUI.OnChanged += x => { this.settings.ScreenSpaceReflections = x; MarkAsModified(); }; screenSpaceReflectionsGUI.OnConfirmed += ConfirmModify; } // FXAA enableFXAAField.OnChanged += x => { this.settings.EnableFXAA = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableFXAAField); ToggleFoldoutFields(); }
/// <summary> /// Refreshes the contents of the content area. Must be called at least once after construction. /// </summary> /// <param name="viewType">Determines how to display the resource tiles.</param> /// <param name="entriesToDisplay">Project library entries to display.</param> /// <param name="bounds">Bounds within which to lay out the content entries.</param> public void Refresh(ProjectViewType viewType, LibraryEntry[] entriesToDisplay, Rect2I bounds) { if (mainPanel != null) { mainPanel.Destroy(); } entries.Clear(); entryLookup.Clear(); mainPanel = parent.Layout.AddPanel(); GUIPanel contentPanel = mainPanel.AddPanel(1); overlay = mainPanel.AddPanel(0); underlay = mainPanel.AddPanel(2); deepUnderlay = mainPanel.AddPanel(3); renameOverlay = mainPanel.AddPanel(-1); main = contentPanel.AddLayoutY(); List <ResourceToDisplay> resourcesToDisplay = new List <ResourceToDisplay>(); foreach (var entry in entriesToDisplay) { if (entry.Type == LibraryEntryType.Directory) { resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single)); } else { FileEntry fileEntry = (FileEntry)entry; ResourceMeta[] metas = fileEntry.ResourceMetas; if (metas.Length > 0) { if (metas.Length == 1) { resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single)); } else { resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.MultiFirst)); for (int i = 1; i < metas.Length - 1; i++) { string path = Path.Combine(entry.Path, metas[i].SubresourceName); resourcesToDisplay.Add(new ResourceToDisplay(path, LibraryGUIEntryType.MultiElement)); } string lastPath = Path.Combine(entry.Path, metas[metas.Length - 1].SubresourceName); resourcesToDisplay.Add(new ResourceToDisplay(lastPath, LibraryGUIEntryType.MultiLast)); } } } } int minHorzElemSpacing = 0; if (viewType == ProjectViewType.List16) { tileSize = 16; gridLayout = false; elementsPerRow = 1; minHorzElemSpacing = 0; int elemWidth = bounds.width; int elemHeight = tileSize; main.AddSpace(TOP_MARGIN); for (int i = 0; i < resourcesToDisplay.Count; i++) { ResourceToDisplay entry = resourcesToDisplay[i]; LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entry.path, i, elemWidth, elemHeight, 0, entry.type); entries.Add(guiEntry); entryLookup[guiEntry.path] = guiEntry; if (i != resourcesToDisplay.Count - 1) { main.AddSpace(LIST_ENTRY_SPACING); } } main.AddFlexibleSpace(); } else { int elemWidth = 0; int elemHeight = 0; int vertElemSpacing = 0; switch (viewType) { case ProjectViewType.Grid64: tileSize = 64; elemWidth = tileSize; elemHeight = tileSize + 36; minHorzElemSpacing = 10; vertElemSpacing = 12; break; case ProjectViewType.Grid48: tileSize = 48; elemWidth = tileSize; elemHeight = tileSize + 36; minHorzElemSpacing = 8; vertElemSpacing = 10; break; case ProjectViewType.Grid32: tileSize = 32; elemWidth = tileSize + 16; elemHeight = tileSize + 48; minHorzElemSpacing = 6; vertElemSpacing = 10; break; } gridLayout = true; int availableWidth = bounds.width; elementsPerRow = MathEx.FloorToInt((availableWidth - minHorzElemSpacing) / (float)(elemWidth + minHorzElemSpacing)); int numRows = MathEx.CeilToInt(resourcesToDisplay.Count / (float)Math.Max(elementsPerRow, 1)); int neededHeight = numRows * elemHeight + TOP_MARGIN; if (numRows > 0) { neededHeight += (numRows - 1) * vertElemSpacing; } bool requiresScrollbar = neededHeight > bounds.height; if (requiresScrollbar) { availableWidth -= parent.ScrollBarWidth; elementsPerRow = MathEx.FloorToInt((availableWidth - minHorzElemSpacing) / (float)(elemWidth + minHorzElemSpacing)); } int extraRowSpace = availableWidth - minHorzElemSpacing * 2 - elementsPerRow * elemWidth; paddingLeft = minHorzElemSpacing; paddingRight = minHorzElemSpacing; float horzSpacing = 0.0f; // Distribute the spacing to the padding, as there are not in-between spaces to apply it to if (extraRowSpace > 0 && elementsPerRow < 2) { int extraPadding = extraRowSpace / 2; paddingLeft += extraPadding; paddingRight += (extraRowSpace - extraPadding); extraRowSpace = 0; } else { horzSpacing = extraRowSpace / (float)(elementsPerRow - 1); } elementsPerRow = Math.Max(elementsPerRow, 1); main.AddSpace(TOP_MARGIN); GUILayoutX rowLayout = main.AddLayoutX(); rowLayout.AddSpace(paddingLeft); float spacingCounter = 0.0f; int elemsInRow = 0; for (int i = 0; i < resourcesToDisplay.Count; i++) { if (elemsInRow == elementsPerRow && elemsInRow > 0) { main.AddSpace(vertElemSpacing); rowLayout = main.AddLayoutX(); rowLayout.AddSpace(paddingLeft); elemsInRow = 0; spacingCounter = 0.0f; } ResourceToDisplay entry = resourcesToDisplay[i]; elemsInRow++; if (elemsInRow != elementsPerRow) { spacingCounter += horzSpacing; } int spacing = (int)spacingCounter; spacingCounter -= spacing; LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, entry.path, i, elemWidth, elemHeight, spacing, entry.type); entries.Add(guiEntry); entryLookup[guiEntry.path] = guiEntry; if (elemsInRow == elementsPerRow) { rowLayout.AddSpace(paddingRight); } rowLayout.AddSpace(spacing); } int extraElements = elementsPerRow - elemsInRow; int extraSpacing = 0; if (extraElements > 1) { spacingCounter += (extraElements - 1) * horzSpacing; extraSpacing += (int)spacingCounter; } if (extraElements > 0) { rowLayout.AddSpace(elemWidth * extraElements + extraSpacing + paddingRight); } main.AddFlexibleSpace(); } // Fix bounds as that makes GUI updates faster underlay.Bounds = main.Bounds; overlay.Bounds = main.Bounds; deepUnderlay.Bounds = main.Bounds; renameOverlay.Bounds = main.Bounds; for (int i = 0; i < entries.Count; i++) { LibraryGUIEntry guiEntry = entries[i]; guiEntry.Initialize(); } }
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> /// Creates a set of objects in which each object represents a GUI for a material parameter. /// </summary> /// <param name="mat">Material for whose parameters to create GUI for.</param> /// <param name="layout">Layout to add the parameter GUI elements to.</param> /// <returns>A material parameter GUI object for each supported material parameter.</returns> static internal MaterialParamGUI[] CreateMaterialGUI(Material mat, GUILayout layout) { Shader shader = mat.Shader; if (shader == null) { return(new MaterialParamGUI[0]); } List <MaterialParamGUI> guiParams = new List <MaterialParamGUI>(); ShaderParameter[] shaderParams = shader.Parameters; foreach (var param in shaderParams) { if (param.isInternal) { continue; } switch (param.type) { case ShaderParameterType.Float: layout.AddSpace(5); guiParams.Add(new MaterialParamFloatGUI(param, mat, layout)); break; case ShaderParameterType.Vector2: layout.AddSpace(5); guiParams.Add(new MaterialParamVec2GUI(param, mat, layout)); break; case ShaderParameterType.Vector3: layout.AddSpace(5); guiParams.Add(new MaterialParamVec3GUI(param, mat, layout)); break; case ShaderParameterType.Vector4: layout.AddSpace(5); guiParams.Add(new MaterialParamVec4GUI(param, mat, layout)); break; case ShaderParameterType.Matrix3: layout.AddSpace(5); guiParams.Add(new MaterialParamMat3GUI(param, mat, layout)); break; case ShaderParameterType.Matrix4: layout.AddSpace(5); guiParams.Add(new MaterialParamMat4GUI(param, mat, layout)); break; case ShaderParameterType.Color: layout.AddSpace(5); guiParams.Add(new MaterialParamColorGUI(param, mat, layout)); break; case ShaderParameterType.Texture2D: case ShaderParameterType.Texture3D: case ShaderParameterType.TextureCube: layout.AddSpace(5); guiParams.Add(new MaterialParamTextureGUI(param, mat, layout)); break; } } return(guiParams.ToArray()); }
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.ScaleToFit); 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; }
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 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; }