/// <summary> /// Constructs a new set of GUI elements for inspecting the limit object. /// </summary> /// <param name="limit">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 LimitAngularRangeGUI(LimitAngularRange limit, GUILayout layout, SerializableProperties properties) { this.limitData = limit.Data; limitLowerField.OnChanged += x => { limitData.lower = new Degree(x); MarkAsModified(); }; limitLowerField.OnFocusLost += ConfirmModify; limitUpperField.OnChanged += x => { limitData.upper = new Degree(x); MarkAsModified(); }; limitUpperField.OnFocusLost += ConfirmModify; layout.AddElement(limitLowerField); layout.AddElement(limitUpperField); limitCommonGUI = new LimitCommonGUI("angularRange", limit.CommonData, layout, properties); limitCommonGUI.OnChanged += x => MarkAsModified(); limitCommonGUI.OnConfirmed += ConfirmModify; }
/// <summary> /// Constructs a new set of GUI elements for inspecting the drive object. /// </summary> /// <param name="drive">Initial values to assign to the GUI elements.</param> /// <param name="layout">Layout to append the GUI elements to.</param> public D6JointDriveGUI(D6JointDrive drive, GUILayout layout) { driveData = drive.Data; stiffnessField.OnChanged += x => { driveData.stiffness = x; MarkAsModified(); }; stiffnessField.OnFocusLost += ConfirmModify; stiffnessField.OnConfirmed += ConfirmModify; dampingField.OnChanged += x => { driveData.damping = x; MarkAsModified(); }; dampingField.OnFocusLost += ConfirmModify; dampingField.OnConfirmed += ConfirmModify; forceLimitField.OnChanged += x => { driveData.forceLimit = x; MarkAsModified(); }; forceLimitField.OnFocusLost += ConfirmModify; forceLimitField.OnConfirmed += ConfirmModify; accelerationField.OnChanged += x => { driveData.acceleration = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(stiffnessField); layout.AddElement(dampingField); layout.AddElement(forceLimitField); layout.AddElement(accelerationField); }
/// <summary> /// Creates a new empty list view. /// </summary> /// <param name="width">Width of the list view, in pixels.</param> /// <param name="height">Height of the list view, in pixels.</param> /// <param name="entryHeight">Height of a single element in the list, in pixels.</param> /// <param name="layout">GUI layout into which the list view will be placed into.</param> protected GUIListViewBase(int width, int height, int entryHeight, GUILayout layout) { scrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow, GUIOption.FixedWidth(width), GUIOption.FixedHeight(height)); layout.AddElement(scrollArea); topPadding = new GUILabel(new LocString()); bottomPadding = new GUILabel(new LocString()); scrollArea.Layout.AddElement(topPadding); scrollArea.Layout.AddElement(bottomPadding); this.width = width; this.height = height; this.entryHeight = entryHeight; }
/// <summary> /// Creates a new GUIFieldSelector and registers its GUI elements in the provided layout. /// </summary> /// <param name="layout">Layout into which to add the selector GUI hierarchy.</param> /// <param name="so">Scene object to inspect the fields for.</param> /// <param name="width">Width of the selector area, in pixels.</param> /// <param name="height">Height of the selector area, in pixels.</param> public GUIFieldSelector(GUILayout layout, SceneObject so, int width, int height) { rootSO = so; scrollArea = new GUIScrollArea(); scrollArea.SetWidth(width); scrollArea.SetHeight(height); layout.AddElement(scrollArea); GUISkin skin = EditorBuiltin.GUISkin; GUIElementStyle style = skin.GetStyle(EditorStyles.Expand); foldoutWidth = style.Width; Rebuild(); }
/// <summary> /// Constructs a new set of GUI elements for inspecting the auto exposure 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> public AutoExposureSettingsGUI(AutoExposureSettings settings, GUILayout layout) { this.settings = settings; histogramLog2MinField.OnChanged += x => { this.settings.HistogramLog2Min = x; MarkAsModified(); ConfirmModify(); }; histogramLog2MaxField.OnChanged += x => { this.settings.HistogramLog2Max = x; MarkAsModified(); ConfirmModify(); }; histogramPctLowField.OnChanged += x => { this.settings.HistogramPctLow = x; MarkAsModified(); ConfirmModify(); }; histogramPctHighField.OnChanged += x => { this.settings.HistogramPctHigh = x; MarkAsModified(); ConfirmModify(); }; minEyeAdaptationField.OnChanged += x => { this.settings.MinEyeAdaptation = x; MarkAsModified(); ConfirmModify(); }; maxEyeAdaptationField.OnChanged += x => { this.settings.MaxEyeAdaptation = x; MarkAsModified(); ConfirmModify(); }; eyeAdaptationSpeedUpField.OnChanged += x => { this.settings.EyeAdaptationSpeedUp = x; MarkAsModified(); ConfirmModify(); }; eyeAdaptationSpeedDownField.OnChanged += x => { this.settings.EyeAdaptationSpeedDown = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(histogramLog2MinField); layout.AddElement(histogramLog2MaxField); layout.AddElement(histogramPctLowField); layout.AddElement(histogramPctHighField); layout.AddElement(minEyeAdaptationField); layout.AddElement(maxEyeAdaptationField); layout.AddElement(eyeAdaptationSpeedUpField); layout.AddElement(eyeAdaptationSpeedDownField); }
/// <summary> /// Builds GUI for the specified GUI element style. /// </summary> /// <param name="layout">Layout to append the GUI elements to.</param> /// <param name="depth">Determines the depth at which the element is rendered.</param> public void BuildGUI(GUILayout layout, int depth) { short backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1); string bgPanelStyle = depth % 2 == 0 ? EditorStyles.InspectorContentBgAlternate : EditorStyles.InspectorContentBg; GUIToggle foldout = new GUIToggle(new LocEdString("Style"), EditorStyles.Foldout); GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle); layout.AddElement(foldout); GUIPanel panel = layout.AddPanel(); GUIPanel backgroundPanel = panel.AddPanel(backgroundDepth); backgroundPanel.AddElement(inspectorContentBg); GUILayoutX guiIndentLayoutX = panel.AddLayoutX(); guiIndentLayoutX.AddSpace(IndentAmount); GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); GUILayoutY contentLayout = guiIndentLayoutY.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiIndentLayoutX.AddSpace(IndentAmount); fontField = new GUIResourceField(typeof (Font), new LocEdString("Font")); fontSizeField = new GUIIntField(new LocEdString("Font size")); horzAlignField = new GUIEnumField(typeof (TextHorzAlign), new LocEdString("Horizontal alignment")); vertAlignField = new GUIEnumField(typeof(TextVertAlign), new LocEdString("Vertical alignment")); imagePositionField = new GUIEnumField(typeof(GUIImagePosition), new LocEdString("Image position")); wordWrapField = new GUIToggleField(new LocEdString("Word wrap")); contentLayout.AddElement(fontField); contentLayout.AddElement(fontSizeField); contentLayout.AddElement(horzAlignField); contentLayout.AddElement(vertAlignField); contentLayout.AddElement(imagePositionField); contentLayout.AddElement(wordWrapField); normalGUI.BuildGUI(new LocEdString("Normal"), contentLayout); hoverGUI.BuildGUI(new LocEdString("Hover"), contentLayout); activeGUI.BuildGUI(new LocEdString("Active"), contentLayout); focusedGUI.BuildGUI(new LocEdString("Focused"), contentLayout); normalOnGUI.BuildGUI(new LocEdString("NormalOn"), contentLayout); hoverOnGUI.BuildGUI(new LocEdString("HoverOn"), contentLayout); activeOnGUI.BuildGUI(new LocEdString("ActiveOn"), contentLayout); focusedOnGUI.BuildGUI(new LocEdString("FocusedOn"), contentLayout); borderGUI = new RectOffsetGUI(new LocEdString("Border"), contentLayout); marginsGUI = new RectOffsetGUI(new LocEdString("Margins"), contentLayout); contentOffsetGUI = new RectOffsetGUI(new LocEdString("Content offset"), contentLayout); fixedWidthField = new GUIToggleField(new LocEdString("Fixed width")); widthField = new GUIIntField(new LocEdString("Width")); minWidthField = new GUIIntField(new LocEdString("Min. width")); maxWidthField = new GUIIntField(new LocEdString("Max. width")); fixedHeightField = new GUIToggleField(new LocEdString("Fixed height")); heightField = new GUIIntField(new LocEdString("Height")); minHeightField = new GUIIntField(new LocEdString("Min. height")); maxHeightField = new GUIIntField(new LocEdString("Max. height")); contentLayout.AddElement(fixedWidthField); contentLayout.AddElement(widthField); contentLayout.AddElement(minWidthField); contentLayout.AddElement(maxWidthField); contentLayout.AddElement(fixedHeightField); contentLayout.AddElement(heightField); contentLayout.AddElement(minHeightField); contentLayout.AddElement(maxHeightField); foldout.OnToggled += x => { panel.Active = x; isExpanded = x; }; fontField.OnChanged += x => { Font font = Resources.Load<Font>(x); GetStyle().Font = font; MarkAsModified(); ConfirmModify(); }; fontSizeField.OnChanged += x => { GetStyle().FontSize = x; MarkAsModified(); }; fontSizeField.OnFocusLost += ConfirmModify; fontSizeField.OnConfirmed += ConfirmModify; horzAlignField.OnSelectionChanged += x => { GetStyle().TextHorzAlign = (TextHorzAlign)x; MarkAsModified(); ConfirmModify(); }; vertAlignField.OnSelectionChanged += x => { GetStyle().TextVertAlign = (TextVertAlign)x; MarkAsModified(); ConfirmModify(); }; imagePositionField.OnSelectionChanged += x => { GetStyle().ImagePosition = (GUIImagePosition)x; MarkAsModified(); ConfirmModify(); }; wordWrapField.OnChanged += x => { GetStyle().WordWrap = x; MarkAsModified(); ConfirmModify(); }; normalGUI.OnChanged += x => { GetStyle().Normal = x; MarkAsModified(); ConfirmModify(); }; hoverGUI.OnChanged += x => { GetStyle().Hover = x; MarkAsModified(); ConfirmModify(); }; activeGUI.OnChanged += x => { GetStyle().Active = x; MarkAsModified(); ConfirmModify(); }; focusedGUI.OnChanged += x => { GetStyle().Focused = x; MarkAsModified(); ConfirmModify(); }; normalOnGUI.OnChanged += x => { GetStyle().NormalOn = x; MarkAsModified(); ConfirmModify(); }; hoverOnGUI.OnChanged += x => { GetStyle().HoverOn = x; MarkAsModified(); ConfirmModify(); }; activeOnGUI.OnChanged += x => { GetStyle().ActiveOn = x; MarkAsModified(); ConfirmModify(); }; focusedOnGUI.OnChanged += x => { GetStyle().FocusedOn = x; MarkAsModified(); ConfirmModify(); }; borderGUI.OnChanged += x => { GetStyle().Border = x; MarkAsModified(); }; marginsGUI.OnChanged += x => { GetStyle().Margins = x; MarkAsModified(); }; contentOffsetGUI.OnChanged += x => { GetStyle().ContentOffset = x; MarkAsModified(); }; borderGUI.OnConfirmed += ConfirmModify; marginsGUI.OnConfirmed += ConfirmModify; contentOffsetGUI.OnConfirmed += ConfirmModify; fixedWidthField.OnChanged += x => { GetStyle().FixedWidth = x; MarkAsModified(); ConfirmModify(); }; widthField.OnChanged += x => GetStyle().Width = x; widthField.OnFocusLost += ConfirmModify; widthField.OnConfirmed += ConfirmModify; minWidthField.OnChanged += x => GetStyle().MinWidth = x; minWidthField.OnFocusLost += ConfirmModify; minWidthField.OnConfirmed += ConfirmModify; maxWidthField.OnChanged += x => GetStyle().MaxWidth = x; maxWidthField.OnFocusLost += ConfirmModify; maxWidthField.OnConfirmed += ConfirmModify; fixedHeightField.OnChanged += x => { GetStyle().FixedHeight = x; MarkAsModified(); ConfirmModify(); }; heightField.OnChanged += x => GetStyle().Height = x; heightField.OnFocusLost += ConfirmModify; heightField.OnConfirmed += ConfirmModify; minHeightField.OnChanged += x => GetStyle().MinHeight = x; minHeightField.OnFocusLost += ConfirmModify; minHeightField.OnConfirmed += ConfirmModify; maxHeightField.OnChanged += x => GetStyle().MaxHeight = x; maxHeightField.OnFocusLost += ConfirmModify; maxHeightField.OnConfirmed += ConfirmModify; foldout.Value = isExpanded; panel.Active = isExpanded; }
/// <summary> /// Recreates the entire curve editor GUI depending on the currently selected scene object. /// </summary> private void RebuildGUI() { GUI.Clear(); guiCurveEditor = null; guiFieldDisplay = null; if (selectedSO == null) { GUILabel warningLbl = new GUILabel(new LocEdString("Select an object to animate in the Hierarchy or Scene windows.")); GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX horzLayout = vertLayout.AddLayoutX(); vertLayout.AddFlexibleSpace(); horzLayout.AddFlexibleSpace(); horzLayout.AddElement(warningLbl); horzLayout.AddFlexibleSpace(); return; } // Top button row GUIContent playIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Play), new LocEdString("Play")); GUIContent recordIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Record), new LocEdString("Record")); GUIContent prevFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameBack), new LocEdString("Previous frame")); GUIContent nextFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameForward), new LocEdString("Next frame")); GUIContent addKeyframeIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddKeyframe), new LocEdString("Add keyframe")); GUIContent addEventIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddEvent), new LocEdString("Add event")); GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options), new LocEdString("Options")); playButton = new GUIToggle(playIcon, EditorStyles.Button); recordButton = new GUIToggle(recordIcon, EditorStyles.Button); prevFrameButton = new GUIButton(prevFrameIcon); frameInputField = new GUIIntField(); nextFrameButton = new GUIButton(nextFrameIcon); addKeyframeButton = new GUIButton(addKeyframeIcon); addEventButton = new GUIButton(addEventIcon); optionsButton = new GUIButton(optionsIcon); playButton.OnToggled += x => { if(x) SwitchState(State.Playback); else SwitchState(State.Normal); }; recordButton.OnToggled += x => { if (x) SwitchState(State.Recording); else SwitchState(State.Normal); }; prevFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx - 1); switch (state) { case State.Recording: case State.Normal: PreviewFrame(currentFrameIdx); break; default: SwitchState(State.Normal); break; } }; frameInputField.OnChanged += x => { SetCurrentFrame(x); switch (state) { case State.Recording: case State.Normal: PreviewFrame(currentFrameIdx); break; default: SwitchState(State.Normal); break; } }; nextFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx + 1); switch (state) { case State.Recording: case State.Normal: PreviewFrame(currentFrameIdx); break; default: SwitchState(State.Normal); break; } }; addKeyframeButton.OnClick += () => { SwitchState(State.Normal); guiCurveEditor.AddKeyFrameAtMarker(); }; addEventButton.OnClick += () => { SwitchState(State.Normal); guiCurveEditor.AddEventAtMarker(); }; optionsButton.OnClick += () => { Vector2I openPosition = ScreenToWindowPos(Input.PointerPosition); AnimationOptions dropDown = DropDownWindow.Open<AnimationOptions>(this, openPosition); dropDown.Initialize(this); }; // Property buttons addPropertyBtn = new GUIButton(new LocEdString("Add property")); delPropertyBtn = new GUIButton(new LocEdString("Delete selected")); addPropertyBtn.OnClick += () => { Action openPropertyWindow = () => { Vector2I windowPos = ScreenToWindowPos(Input.PointerPosition); FieldSelectionWindow fieldSelection = DropDownWindow.Open<FieldSelectionWindow>(this, windowPos); fieldSelection.OnFieldSelected += OnFieldAdded; }; if (clipInfo.clip == null) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("Selected object doesn't have an animation clip assigned. Would you like to create" + " a new animation clip?"); DialogBox.Open(title, message, DialogBox.Type.YesNoCancel, type => { if (type == DialogBox.ResultType.Yes) { string clipSavePath; if (BrowseDialog.SaveFile(ProjectLibrary.ResourceFolder, "*.asset", out clipSavePath)) { SwitchState(State.Empty); clipSavePath = Path.ChangeExtension(clipSavePath, ".asset"); AnimationClip newClip = new AnimationClip(); ProjectLibrary.Create(newClip, clipSavePath); LoadAnimClip(newClip); Animation animation = selectedSO.GetComponent<Animation>(); if (animation == null) animation = selectedSO.AddComponent<Animation>(); animation.DefaultClip = newClip; EditorApplication.SetSceneDirty(); SwitchState(State.Normal); openPropertyWindow(); } } }); } else { if (clipInfo.isImported) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("You cannot add/edit/remove curves from animation clips that" + " are imported from an external file."); DialogBox.Open(title, message, DialogBox.Type.OK); } else { SwitchState(State.Normal); openPropertyWindow(); } } }; delPropertyBtn.OnClick += () => { if (clipInfo.clip == null) return; SwitchState(State.Normal); if (clipInfo.isImported) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("You cannot add/edit/remove curves from animation clips that" + " are imported from an external file."); DialogBox.Open(title, message, DialogBox.Type.OK); } else { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("Are you sure you want to remove all selected fields?"); DialogBox.Open(title, message, DialogBox.Type.YesNo, x => { if (x == DialogBox.ResultType.Yes) { RemoveSelectedFields(); ApplyClipChanges(); } }); } }; GUIPanel mainPanel = GUI.AddPanel(); GUIPanel backgroundPanel = GUI.AddPanel(1); GUILayout mainLayout = mainPanel.AddLayoutY(); buttonLayout = mainLayout.AddLayoutX(); buttonLayout.AddSpace(5); buttonLayout.AddElement(playButton); buttonLayout.AddElement(recordButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(prevFrameButton); buttonLayout.AddElement(frameInputField); buttonLayout.AddElement(nextFrameButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(addKeyframeButton); buttonLayout.AddElement(addEventButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(optionsButton); buttonLayout.AddFlexibleSpace(); buttonLayoutHeight = playButton.Bounds.height; GUITexture buttonBackground = new GUITexture(null, EditorStyles.HeaderBackground); buttonBackground.Bounds = new Rect2I(0, 0, Width, buttonLayoutHeight); backgroundPanel.AddElement(buttonBackground); GUILayout contentLayout = mainLayout.AddLayoutX(); GUILayout fieldDisplayLayout = contentLayout.AddLayoutY(GUIOption.FixedWidth(FIELD_DISPLAY_WIDTH)); guiFieldDisplay = new GUIAnimFieldDisplay(fieldDisplayLayout, FIELD_DISPLAY_WIDTH, Height - buttonLayoutHeight * 2, selectedSO); guiFieldDisplay.OnEntrySelected += OnFieldSelected; GUILayout bottomButtonLayout = fieldDisplayLayout.AddLayoutX(); bottomButtonLayout.AddElement(addPropertyBtn); bottomButtonLayout.AddElement(delPropertyBtn); horzScrollBar = new GUIResizeableScrollBarH(); horzScrollBar.OnScrollOrResize += OnHorzScrollOrResize; vertScrollBar = new GUIResizeableScrollBarV(); vertScrollBar.OnScrollOrResize += OnVertScrollOrResize; GUITexture separator = new GUITexture(null, EditorStyles.Separator, GUIOption.FixedWidth(3)); contentLayout.AddElement(separator); GUILayout curveLayout = contentLayout.AddLayoutY(); GUILayout curveLayoutHorz = curveLayout.AddLayoutX(); GUILayout horzScrollBarLayout = curveLayout.AddLayoutX(); horzScrollBarLayout.AddElement(horzScrollBar); horzScrollBarLayout.AddFlexibleSpace(); editorPanel = curveLayoutHorz.AddPanel(); curveLayoutHorz.AddElement(vertScrollBar); curveLayoutHorz.AddFlexibleSpace(); scrollBarHeight = horzScrollBar.Bounds.height; scrollBarWidth = vertScrollBar.Bounds.width; Vector2I curveEditorSize = GetCurveEditorSize(); guiCurveEditor = new GUICurveEditor(this, editorPanel, curveEditorSize.x, curveEditorSize.y); guiCurveEditor.OnFrameSelected += OnFrameSelected; guiCurveEditor.OnEventAdded += OnEventsChanged; guiCurveEditor.OnEventModified += EditorApplication.SetProjectDirty; guiCurveEditor.OnEventDeleted += OnEventsChanged; guiCurveEditor.OnCurveModified += () => { SwitchState(State.Normal); ApplyClipChanges(); PreviewFrame(currentFrameIdx); EditorApplication.SetProjectDirty(); }; guiCurveEditor.OnClicked += () => { if(state != State.Recording) SwitchState(State.Normal); }; guiCurveEditor.Redraw(); horzScrollBar.SetWidth(curveEditorSize.x); vertScrollBar.SetHeight(curveEditorSize.y); UpdateScrollBarSize(); }
private void OnInitialize() { ProjectLibrary.OnEntryAdded += OnEntryChanged; ProjectLibrary.OnEntryImported += OnEntryChanged; ProjectLibrary.OnEntryRemoved += OnEntryChanged; GUILayoutY contentLayout = GUI.AddLayoutY(); searchBarLayout = contentLayout.AddLayoutX(); searchField = new GUITextField(); searchField.OnChanged += OnSearchChanged; searchField.OnFocusGained += StopRename; GUIContent clearIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Clear), new LocEdString("Clear")); GUIButton clearSearchBtn = new GUIButton(clearIcon); clearSearchBtn.OnClick += OnClearClicked; clearSearchBtn.SetWidth(40); GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options), new LocEdString("Options")); optionsButton = new GUIButton(optionsIcon); optionsButton.OnClick += OnOptionsClicked; optionsButton.SetWidth(40); searchBarLayout.AddElement(searchField); searchBarLayout.AddElement(clearSearchBtn); searchBarLayout.AddElement(optionsButton); folderBarLayout = contentLayout.AddLayoutX(); GUIContent homeIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Home), new LocEdString("Home")); GUIButton homeButton = new GUIButton(homeIcon, GUIOption.FixedWidth(FOLDER_BUTTON_WIDTH)); homeButton.OnClick += OnHomeClicked; GUIContent upIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Up), new LocEdString("Up")); GUIButton upButton = new GUIButton(upIcon, GUIOption.FixedWidth(FOLDER_BUTTON_WIDTH)); upButton.OnClick += OnUpClicked; folderBarLayout.AddElement(homeButton); folderBarLayout.AddElement(upButton); folderBarLayout.AddSpace(10); contentScrollArea = new GUIScrollArea(GUIOption.FlexibleWidth(), GUIOption.FlexibleHeight()); contentLayout.AddElement(contentScrollArea); contentLayout.AddFlexibleSpace(); entryContextMenu = LibraryMenu.CreateContextMenu(this); content = new LibraryGUIContent(this, contentScrollArea); Refresh(); dropTarget = new LibraryDropTarget(this); dropTarget.Bounds = GetScrollAreaBounds(); dropTarget.OnStart += OnDragStart; dropTarget.OnDrag += OnDragMove; dropTarget.OnLeave += OnDragLeave; dropTarget.OnDropResource += OnResourceDragDropped; dropTarget.OnDropSceneObject += OnSceneObjectDragDropped; dropTarget.OnEnd += OnDragEnd; Selection.OnSelectionChanged += OnSelectionChanged; Selection.OnResourcePing += OnPing; }
/// <summary> /// Constructs a new set of GUI elements for inspecting the limit object. /// </summary> /// <param name="limit">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 LimitConeRangeGUI(LimitConeRange limit, GUILayout layout, SerializableProperties properties) { this.limitData = limit.Data; yLimitAngleField.OnChanged += x => { limitData.yLimitAngle = new Degree(x); MarkAsModified(); }; yLimitAngleField.OnFocusLost += ConfirmModify; zLimitAngleField.OnChanged += x => { limitData.zLimitAngle = new Degree(x); MarkAsModified(); }; zLimitAngleField.OnFocusLost += ConfirmModify; layout.AddElement(yLimitAngleField); layout.AddElement(zLimitAngleField); limitCommonGUI = new LimitCommonGUI("coneRange", limit.CommonData, layout, properties); limitCommonGUI.OnChanged += x => MarkAsModified(); limitCommonGUI.OnConfirmed += ConfirmModify; }
/// <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> /// Creates a new material parameter GUI. /// </summary> /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of 4D vector 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 MaterialParamVec4GUI(ShaderParameter shaderParam, Material material, GUILayout layout) : base(shaderParam) { LocString title = new LocEdString(shaderParam.Name); guiElem = new GUIVector4Field(title); guiElem.OnChanged += (x) => { material.SetVector4(shaderParam.Name, x); EditorApplication.SetDirty(material); }; layout.AddElement(guiElem); }
/// <summary> /// Creates a new material parameter GUI. /// </summary> /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of texture 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 MaterialParamTextureGUI(ShaderParameter shaderParam, Material material, GUILayout layout) : base(shaderParam) { LocString title = new LocEdString(shaderParam.Name); guiElem = new GUITextureField(title); switch (shaderParam.Type) { case ShaderParameterType.Texture2D: guiElem.OnChanged += (x) => { Texture2D texture = Resources.Load<Texture2D>(x); material.SetTexture2D(shaderParam.Name, texture); EditorApplication.SetDirty(material); }; break; case ShaderParameterType.Texture3D: guiElem.OnChanged += (x) => { Texture3D texture = Resources.Load<Texture3D>(x); material.SetTexture3D(shaderParam.Name, texture); EditorApplication.SetDirty(material); }; break; case ShaderParameterType.TextureCube: guiElem.OnChanged += (x) => { TextureCube texture = Resources.Load<TextureCube>(x); material.SetTextureCube(shaderParam.Name, texture); EditorApplication.SetDirty(material); }; break; } layout.AddElement(guiElem); }
/// <summary> /// Constructs a new set of GUI elements for inspecting the spring object. /// </summary> /// <param name="spring">Initial values to assign to the GUI elements.</param> /// <param name="layout">Layout to append the GUI elements to.</param> public SpringGUI(Spring spring, GUILayout layout) { this.spring = spring; stiffnessField.OnChanged += x => { spring.stiffness = x; MarkAsModified(); }; stiffnessField.OnFocusLost += ConfirmModify; stiffnessField.OnConfirmed += ConfirmModify; dampingField.OnChanged += x => { spring.damping = x; MarkAsModified(); }; dampingField.OnFocusLost += ConfirmModify; dampingField.OnConfirmed += ConfirmModify; layout.AddElement(stiffnessField); layout.AddElement(dampingField); }
/// <summary> /// Constructs a new set of GUI elements for inspecting the limit object. /// </summary> /// <param name="limit">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 LimitLinearGUI(LimitLinear limit, GUILayout layout, SerializableProperties properties) { limitData = limit.Data; limitExtentField.OnChanged += x => { limitData.extent = x; MarkAsModified(); }; limitExtentField.OnFocusLost += ConfirmModify; layout.AddElement(limitExtentField); limitCommonGUI = new LimitCommonGUI("linear", limit.CommonData, layout, properties); limitCommonGUI.OnChanged += x => MarkAsModified(); limitCommonGUI.OnConfirmed += ConfirmModify; }
/// <summary> /// Builds the GUI for the specified state style. /// </summary> /// <param name="title">Text to display on the title bar.</param> /// <param name="layout">Layout to append the GUI elements to.</param> public void BuildGUI(LocString title, GUILayout layout) { foldout = new GUIToggle(title, EditorStyles.Foldout); textureField = new GUIResourceField(typeof(SpriteTexture), new LocEdString("Texture")); textColorField = new GUIColorField(new LocEdString("Text color")); foldout.OnToggled += x => { textureField.Active = x; textColorField.Active = x; isExpanded = x; }; textureField.OnChanged += x => { SpriteTexture texture = Resources.Load<SpriteTexture>(x); state.Texture = texture; if (OnChanged != null) OnChanged(state); }; textColorField.OnChanged += x => { state.TextColor = x; if (OnChanged != null) OnChanged(state); }; layout.AddElement(foldout); layout.AddElement(textureField); layout.AddElement(textColorField); foldout.Value = isExpanded; textureField.Active = isExpanded; textColorField.Active = isExpanded; }
/// <summary> /// Constructs a new set of GUI elements for inspecting the color grading 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> public ColorGradingSettingsGUI(ColorGradingSettings settings, GUILayout layout) { this.settings = settings; saturationField.OnChanged += x => { this.settings.Saturation = x; MarkAsModified(); }; saturationField.OnFocusLost += ConfirmModify; saturationField.OnConfirmed += ConfirmModify; contrastField.OnChanged += x => { this.settings.Contrast = x; MarkAsModified(); }; contrastField.OnFocusLost += ConfirmModify; contrastField.OnConfirmed += ConfirmModify; gainField.OnChanged += x => { this.settings.Gain = x; MarkAsModified(); }; gainField.OnFocusLost += ConfirmModify; gainField.OnConfirmed += ConfirmModify; offsetField.OnChanged += x => { this.settings.Offset = x; MarkAsModified(); }; offsetField.OnFocusLost += ConfirmModify; offsetField.OnConfirmed += ConfirmModify; layout.AddElement(saturationField); layout.AddElement(contrastField); layout.AddElement(gainField); layout.AddElement(offsetField); }
/// <summary> /// Constructs a new animation field entry and appends the necessary GUI elements to the provided layouts. /// </summary> /// <param name="layouts">Layouts to append the GUI elements to.</param> /// <param name="path">Path of the curve field.</param> /// <param name="childEntries">Sub-path names of the child entries to display.</param> /// <param name="colors">Colors of the curves to display, for each child entry.</param> public GUIAnimComplexEntry(GUIAnimFieldLayouts layouts, string path, string[] childEntries, Color[] colors) : base(layouts, path, false, 20) { foldout = new GUIToggle("", EditorStyles.Expand); foldout.OnToggled += Toggle; GUILabel spacer = new GUILabel("", GUIOption.FixedHeight(GetEntryHeight())); foldoutLayout = layouts.overlay.AddLayoutX(); foldoutLayout.AddSpace(5); foldoutLayout.AddElement(foldout); foldoutLayout.AddElement(spacer); foldoutLayout.AddFlexibleSpace(); underlaySpacing = new GUILabel("", GUIOption.FixedHeight(GetEntryHeight())); layouts.underlay.AddElement(underlaySpacing); children = new GUIAnimSimpleEntry[childEntries.Length]; for (int i = 0; i < childEntries.Length; i++) { Color color; if (i < colors.Length) color = colors[i]; else color = Color.White; children[i] = new GUIAnimSimpleEntry(layouts, path + childEntries[i], color, true); children[i].OnEntrySelected += x => { OnEntrySelected?.Invoke(x); }; } Toggle(false); }
/// <summary> /// Constructs a new set of GUI elements for inspecting the tone mapping 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> public TonemappingSettingsGUI(TonemappingSettings settings, GUILayout layout) { this.settings = settings; shoulderStrengthField.OnChanged += x => { this.settings.FilmicCurveShoulderStrength = x; MarkAsModified(); }; shoulderStrengthField.OnFocusLost += ConfirmModify; shoulderStrengthField.OnConfirmed += ConfirmModify; linearStrengthField.OnChanged += x => { this.settings.FilmicCurveLinearStrength = x; MarkAsModified(); }; linearStrengthField.OnFocusLost += ConfirmModify; linearStrengthField.OnConfirmed += ConfirmModify; linearAngleField.OnChanged += x => { this.settings.FilmicCurveLinearAngle = x; MarkAsModified(); }; linearAngleField.OnFocusLost += ConfirmModify; linearAngleField.OnConfirmed += ConfirmModify; toeStrengthField.OnChanged += x => { this.settings.FilmicCurveToeStrength = x; MarkAsModified(); }; toeStrengthField.OnFocusLost += ConfirmModify; toeStrengthField.OnConfirmed += ConfirmModify; toeNumeratorField.OnChanged += x => { this.settings.FilmicCurveToeNumerator = x; MarkAsModified(); }; toeNumeratorField.OnFocusLost += ConfirmModify; toeNumeratorField.OnConfirmed += ConfirmModify; toeDenominatorField.OnChanged += x => { this.settings.FilmicCurveToeDenominator = x; MarkAsModified(); }; toeDenominatorField.OnFocusLost += ConfirmModify; toeDenominatorField.OnConfirmed += ConfirmModify; whitePointField.OnChanged += x => { this.settings.FilmicCurveLinearWhitePoint = x; MarkAsModified(); }; whitePointField.OnFocusLost += ConfirmModify; whitePointField.OnConfirmed += ConfirmModify; layout.AddElement(shoulderStrengthField); layout.AddElement(linearStrengthField); layout.AddElement(linearAngleField); layout.AddElement(toeStrengthField); layout.AddElement(toeNumeratorField); layout.AddElement(toeDenominatorField); layout.AddElement(whitePointField); }
/// <summary> /// Creates a new animation field display GUI element and adds it to the provided layout. /// </summary> /// <param name="layout">Layout to add the GUI element to.</param> /// <param name="width">Width of the GUI element, in pixels.</param> /// <param name="height">Height of the GUI element, in pixels.</param> /// <param name="root">Scene object that the root curve field paths reference.</param> public GUIAnimFieldDisplay(GUILayout layout, int width, int height, SceneObject root) { this.root = root; scrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow); layout.AddElement(scrollArea); SetSize(width, height); }
/// <summary> /// Constructs a new set of GUI elements for inspecting the white balance 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> public WhiteBalanceSettingsGUI(WhiteBalanceSettings settings, GUILayout layout) { this.settings = settings; temperatureField.OnChanged += x => { this.settings.Temperature = x; MarkAsModified(); ConfirmModify(); }; tintField.OnChanged += x => { this.settings.Tint = x; MarkAsModified(); ConfirmModify(); }; layout.AddElement(temperatureField); layout.AddElement(tintField); }
/// <summary> /// Constructs a new set of GUI elements for inspecting the limit object. /// </summary> /// <param name="prefix">Prefix that identifies the exact type of the limit type.</param> /// <param name="limitData">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 LimitCommonGUI(string prefix, LimitCommonData limitData, GUILayout layout, SerializableProperties properties) { this.limitData = limitData; this.properties = properties; this.prefix = prefix; hardFoldout.OnToggled += x => { properties.SetBool(prefix + "_hardLimit_Expanded", x); ToggleLimitFields(); }; contactDistanceField.OnChanged += x => { this.limitData.contactDist = x; MarkAsModified(); }; contactDistanceField.OnFocusLost += ConfirmModify; contactDistanceField.OnConfirmed += ConfirmModify; softFoldout.OnToggled += x => { properties.SetBool(prefix + "_softLimit_Expanded", x); ToggleLimitFields(); }; restitutionField.OnChanged += x => { this.limitData.restitution = x; MarkAsModified(); }; restitutionField.OnFocusLost += ConfirmModify; springFoldout.OnToggled += x => { properties.SetBool(prefix + "_spring_Expanded", x); ToggleLimitFields(); }; hardLimitLayout = layout.AddLayoutX(); { hardLimitLayout.AddSpace(10); GUILayoutY hardLimitContentsLayout = hardLimitLayout.AddLayoutY(); hardLimitContentsLayout.AddElement(contactDistanceField); } softLimitLayout = layout.AddLayoutX(); layout.AddElement(softFoldout); { softLimitLayout.AddSpace(10); GUILayoutY softLimitContentsLayout = softLimitLayout.AddLayoutY(); softLimitContentsLayout.AddElement(restitutionField); softLimitContentsLayout.AddElement(springFoldout); springLayout = softLimitContentsLayout.AddLayoutX(); { springLayout.AddSpace(10); GUILayoutY springContentsLayout = springLayout.AddLayoutY(); springGUI = new SpringGUI(limitData.spring, springContentsLayout); springGUI.OnChanged += x => { this.limitData.spring = x; MarkAsModified(); }; springGUI.OnConfirmed += ConfirmModify; } } }