/// <summary> /// Initializes the inspector. Must be called after construction. /// </summary> /// <param name="gui">GUI panel to add the GUI elements to.</param> /// <param name="instance">Instance of the object whose fields to display GUI for.</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> internal virtual void Initialize(GUIPanel gui, object instance, 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, EditorStyles.InspectorContentBg); backgroundPanel.AddElement(inspectorContentBg); mainPanel = contentPanel; layout = GUI.AddLayoutY(); inspectedObject = instance; Initialize(); Refresh(); }
/// <summary> /// Constructs a new GUI list. /// </summary> /// <param name="title">Label to display on the list GUI title.</param> /// <param name="layout">Layout to which to append the array GUI elements to.</param> /// <param name="depth">Determines at which depth to render the background. Useful when you have multiple /// nested containers whose backgrounds are overlaping. Also determines background style, /// depths divisible by two will use an alternate style.</param> protected GUIListFieldBase(LocString title, GUILayout layout, int depth) { this.title = title; this.depth = depth; guiLayout = layout.AddLayoutY(); guiTitleLayout = guiLayout.AddLayoutX(); }
/// <summary> /// Common code called by both Initialize() overloads. /// </summary> /// <param name="mainGui">Primary GUI panel to add the GUI elements to.</param> /// <param name="previewGui">Secondary GUI panel located at the bottom of the inspector window, aimed primarily for /// resource previews, but can be used for any purpose.</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 mainGui, GUIPanel previewGui, SerializableProperties persistent) { rootGUI = mainGui; this.persistent = persistent; GUILayout contentLayoutX = mainGui.AddLayoutX(); contentLayoutX.AddSpace(5); GUILayout contentLayoutY = contentLayoutX.AddLayoutY(); contentLayoutY.AddSpace(5); GUIPanel contentPanel = contentLayoutY.AddPanel(); contentLayoutY.AddSpace(5); contentLayoutX.AddSpace(5); GUIPanel backgroundPanel = mainGui.AddPanel(START_BACKGROUND_DEPTH); GUITexture inspectorContentBg = new GUITexture(null, EditorStylesInternal.InspectorContentBg); backgroundPanel.AddElement(inspectorContentBg); mainPanel = contentPanel; previewPanel = previewGui; layout = GUI.AddLayoutY(); }
/// <summary> /// Registers a new row in the layout. The row cannot be selected as the output field, but rather can be expanded /// so it displays child elements. /// </summary> /// <param name="layout">Layout to append the row GUI elements to.</param> /// <param name="icon">Optional icon to display next to the name. Can be null.</param> /// <param name="name">Name of the field.</param> /// <param name="so">Parent scene object of the field.</param> /// <param name="component">Parent component of the field. Can be null if field belongs to <see cref="SceneObject"/>. /// </param> /// <param name="path">Slash separated path to the field from its parent object.</param> /// <param name="toggleCallback">Callback to trigger when the user expands or collapses the foldout.</param> /// <returns>Element object storing all information about the added field.</returns> private Element AddFoldoutRow(GUILayout layout, SpriteTexture icon, string name, SceneObject so, Component component, string path, Action <Element, bool> toggleCallback) { Element element = new Element(so, component, path); GUILayoutY elementLayout = layout.AddLayoutY(); GUILayoutX foldoutLayout = elementLayout.AddLayoutX(); element.toggle = new GUIToggle("", EditorStyles.Expand); element.toggle.OnToggled += x => toggleCallback(element, x); foldoutLayout.AddSpace(PADDING); foldoutLayout.AddElement(element.toggle); if (icon != null) { GUITexture guiIcon = new GUITexture(icon, GUIOption.FixedWidth(16), GUIOption.FixedWidth(16)); foldoutLayout.AddElement(guiIcon); } GUILabel label = new GUILabel(new LocEdString(name)); foldoutLayout.AddElement(label); foldoutLayout.AddFlexibleSpace(); element.indentLayout = elementLayout.AddLayoutX(); element.indentLayout.AddSpace(INDENT_AMOUNT); element.childLayout = element.indentLayout.AddLayoutY(); element.indentLayout.Active = false; return(element); }
/// <summary> /// Initializes the row and creates row GUI elements. /// </summary> /// <param name="parent">Parent array GUI object that the entry is contained in.</param> /// <param name="parentLayout">Parent layout that row GUI elements will be added to.</param> /// <param name="rowIdx">Sequential index of the row.</param> /// <param name="depth">Determines the depth at which the element is rendered.</param> internal void Initialize(GUIDictionaryFieldBase parent, GUILayout parentLayout, int rowIdx, int depth) { this.parent = parent; this.rowIdx = rowIdx; this.depth = depth; rowLayout = parentLayout.AddLayoutY(); keyRowLayout = rowLayout.AddLayoutX(); keyLayout = keyRowLayout.AddLayoutY(); valueLayout = rowLayout.AddLayoutY(); BuildGUI(); }
/// <summary> /// Builds the portion of the GUI that displays details about individual materials. /// </summary> private void BuildMaterialsGUI() { materialsLayout.Clear(); materialParams.Clear(); materialVariations.Clear(); if (materials != null && materials.Length > 0) { for (int i = 0; i < materials.Length; i++) { string suffix = ""; if (materials.Length > 1) { suffix = " (" + i + ")"; } materialsLayout.AddSpace(10); GUIToggle foldout = new GUIToggle(new LocEdString("Material parameters" + suffix), EditorStyles.Foldout); materialsLayout.AddElement(foldout); GUILayoutY materialLayout = materialsLayout.AddLayoutY(); string tag = "Material" + i + "_Expanded"; foldout.OnToggled += x => { materialLayout.Active = x; Persistent.SetBool(tag, x); }; materialLayout.Active = Persistent.GetBool(tag); Material material = materials[i].Value; if (material == null) { materialParams.Add(new MaterialParamGUI[0]); continue; } MaterialVariationGUI variationGUI = new MaterialVariationGUI(material, materialLayout); materialVariations.Add(variationGUI); MaterialParamGUI[] matParams = MaterialInspector.CreateMaterialGUI(material, "materialParams[" + i + "]", null, materialLayout); materialParams.Add(matParams); } } }
/// <summary> /// Creates a new material parameter GUI. /// </summary> /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of 4x4 matrix type.</param> /// <param name="material">Material the parameter is a part of.</param> /// <param name="layout">Layout to append the GUI elements to.</param> internal MaterialParamMat4GUI(ShaderParameter shaderParam, Material material, GUILayout layout) : base(shaderParam) { LocString title = new LocEdString(shaderParam.name); GUILabel guiTitle = new GUILabel(title, GUIOption.FixedWidth(100)); mainLayout = layout.AddLayoutY(); GUILayoutX titleLayout = mainLayout.AddLayoutX(); titleLayout.AddElement(guiTitle); titleLayout.AddFlexibleSpace(); GUILayoutY contentLayout = mainLayout.AddLayoutY(); GUILayoutX[] rows = new GUILayoutX[MAT_SIZE]; for (int i = 0; i < rows.Length; i++) { rows[i] = contentLayout.AddLayoutX(); } for (int row = 0; row < MAT_SIZE; row++) { for (int col = 0; col < MAT_SIZE; col++) { int index = row * MAT_SIZE + col; guiMatFields[index] = new GUIFloatField(row + "," + col, 20, "", GUIOption.FixedWidth(80)); GUIFloatField field = guiMatFields[index]; rows[row].AddElement(field); rows[row].AddSpace(5); int hoistedRow = row; int hoistedCol = col; field.OnChanged += (x) => { Matrix4 value = material.GetMatrix4(shaderParam.name); value[hoistedRow, hoistedCol] = x; material.SetMatrix4(shaderParam.name, value); EditorApplication.SetDirty(material); }; } } }
/// <summary> /// Constructs a new resource tile entry. /// </summary> /// <param name="owner">Content area this entry is part of.</param> /// <param name="parent">Parent layout to add this entry's GUI elements to.</param> /// <param name="entry">Project library entry this entry displays data for.</param> /// <param name="index">Sequential index of the entry in the conent area.</param> /// <param name="labelWidth">Width of the GUI labels that display the elements.</param> public LibraryGUIEntry(LibraryGUIContent owner, GUILayout parent, LibraryEntry entry, int index, int labelWidth) { GUILayout entryLayout; if (owner.GridLayout) { entryLayout = parent.AddLayoutY(); } else { entryLayout = parent.AddLayoutX(); } SpriteTexture iconTexture = GetIcon(entry, owner.TileSize); icon = new GUITexture(iconTexture, GUIImageScaleMode.ScaleToFit, true, GUIOption.FixedHeight(owner.TileSize), GUIOption.FixedWidth(owner.TileSize)); label = null; if (owner.GridLayout) { label = new GUILabel(entry.Name, EditorStyles.MultiLineLabelCentered, GUIOption.FixedWidth(labelWidth), GUIOption.FlexibleHeight(0, MAX_LABEL_HEIGHT)); } else { label = new GUILabel(entry.Name); } entryLayout.AddElement(icon); entryLayout.AddElement(label); this.owner = owner; this.index = index; this.path = entry.Path; this.bounds = new Rect2I(); this.underlay = null; }
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(); }
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> /// 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> /// 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 PostProcessSettingsGUI(PostProcessSettings settings, GUILayout layout, SerializableProperties properties) { this.settings = settings; this.properties = properties; // Auto exposure enableAutoExposureField.OnChanged += x => { this.settings.EnableAutoExposure = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(enableAutoExposureField); 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.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.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.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); ToggleFoldoutFields(); }
/// <summary> /// Constructs a new resource tile entry. /// </summary> /// <param name="owner">Content area this entry is part of.</param> /// <param name="parent">Parent layout to add this entry's GUI elements to.</param> /// <param name="path">Path to the project library entry to display data for.</param> /// <param name="index">Sequential index of the entry in the conent area.</param> /// <param name="width">Width of the GUI entry.</param> /// <param name="height">Maximum allowed height for the label.</param>" /// <param name="type">Type of the entry, which controls its style and/or behaviour.</param> public LibraryGUIEntry(LibraryGUIContent owner, GUILayout parent, string path, int index, int width, int height, LibraryGUIEntryType type) { GUILayout entryLayout; if (owner.GridLayout) { entryLayout = parent.AddLayoutY(); } else { entryLayout = parent.AddLayoutX(); } SpriteTexture iconTexture = GetIcon(path, owner.TileSize); icon = new GUITexture(iconTexture, GUITextureScaleMode.ScaleToFit, true, GUIOption.FixedHeight(owner.TileSize), GUIOption.FixedWidth(owner.TileSize)); label = null; string name = PathEx.GetTail(path); if (owner.GridLayout) { int labelHeight = height - owner.TileSize; label = new GUILabel(name, EditorStyles.MultiLineLabelCentered, GUIOption.FixedWidth(width), GUIOption.FixedHeight(labelHeight)); switch (type) { case LibraryGUIEntryType.Single: break; case LibraryGUIEntryType.MultiFirst: groupUnderlay = new GUITexture(null, LibraryEntryFirstBg); break; case LibraryGUIEntryType.MultiElement: groupUnderlay = new GUITexture(null, LibraryEntryBg); break; case LibraryGUIEntryType.MultiLast: groupUnderlay = new GUITexture(null, LibraryEntryLastBg); break; } } else { label = new GUILabel(name, GUIOption.FixedWidth(width - owner.TileSize), GUIOption.FixedHeight(height)); switch (type) { case LibraryGUIEntryType.Single: break; case LibraryGUIEntryType.MultiFirst: groupUnderlay = new GUITexture(null, LibraryEntryVertFirstBg); break; case LibraryGUIEntryType.MultiElement: groupUnderlay = new GUITexture(null, LibraryEntryVertBg); break; case LibraryGUIEntryType.MultiLast: groupUnderlay = new GUITexture(null, LibraryEntryVertLastBg); break; } } entryLayout.AddElement(icon); entryLayout.AddElement(label); if (groupUnderlay != null) { owner.DeepUnderlay.AddElement(groupUnderlay); } this.owner = owner; this.index = index; this.path = path; this.bounds = new Rect2I(); this.underlay = null; this.type = type; this.width = width; this.height = height; }
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(); }
/// <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; }; renderSettingsFoldout.AcceptsKeyFocus = false; Layout.AddElement(renderSettingsFoldout); renderSettingsLayout = Layout.AddLayoutX(); { renderSettingsLayout.AddSpace(10); GUILayoutY contentsLayout = renderSettingsLayout.AddLayoutY(); renderSettingsGUI = new InspectorFieldDrawer(new InspectableContext(Persistent, camera), contentsLayout); renderSettingsGUI.AddDefault(camera.RenderSettings); } ToggleTypeSpecificFields(camera.ProjectionType); renderSettingsLayout.Active = Persistent.GetBool("renderSettings_Expanded"); } }
/// <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.ViewportRect; rect.x = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportXField.OnConfirmed += ConfirmModify; viewportXField.OnFocusLost += ConfirmModify; viewportYField.OnChanged += x => { Rect2 rect = camera.ViewportRect; rect.y = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportYField.OnConfirmed += ConfirmModify; viewportYField.OnFocusLost += ConfirmModify; viewportWidthField.OnChanged += x => { Rect2 rect = camera.ViewportRect; rect.width = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportWidthField.OnConfirmed += ConfirmModify; viewportWidthField.OnFocusLost += ConfirmModify; viewportHeightField.OnChanged += x => { Rect2 rect = camera.ViewportRect; rect.height = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportHeightField.OnConfirmed += ConfirmModify; viewportHeightField.OnFocusLost += ConfirmModify; clearFlagsFields.OnSelectionChanged += x => { camera.ClearFlags = (ClearFlags)x; MarkAsModified(); ConfirmModify(); }; clearStencilField.OnChanged += x => { camera.ClearStencil = (ushort)x; }; clearStencilField.OnConfirmed += ConfirmModify; clearStencilField.OnFocusLost += ConfirmModify; clearDepthField.OnChanged += x => { camera.ClearDepth = x; }; clearDepthField.OnConfirmed += ConfirmModify; clearDepthField.OnFocusLost += ConfirmModify; clearColorField.OnChanged += x => { camera.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(); }; hdrField.OnChanged += x => { camera.HDR = x; MarkAsModified(); ConfirmModify(); }; skyboxField.OnChanged += x => { Texture skyboxTex = Resources.Load <Texture>(x); camera.Skybox = skyboxTex as TextureCube; 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); Layout.AddElement(hdrField); Layout.AddElement(skyboxField); postProcessFoldout.OnToggled += x => { Persistent.SetBool("postProcess_Expanded", x); postProcessLayout.Active = x; }; Layout.AddElement(postProcessFoldout); postProcessLayout = Layout.AddLayoutX(); { postProcessLayout.AddSpace(10); GUILayoutY contentsLayout = postProcessLayout.AddLayoutY(); postProcessGUI = new PostProcessSettingsGUI(camera.PostProcess, contentsLayout, Persistent); postProcessGUI.OnChanged += x => { camera.PostProcess = x; MarkAsModified(); }; postProcessGUI.OnConfirmed += ConfirmModify; } ToggleTypeSpecificFields(camera.ProjectionType); postProcessLayout.Active = Persistent.GetBool("postProcess_Expanded"); } }
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(); }