/// <inheritdoc/> protected internal override void Initialize(int layoutIndex) { if (property != null) { guiIntField = new GUIIntField(new GUIContent(title)); guiIntField.OnChanged += OnFieldValueChanged; guiIntField.OnConfirmed += OnFieldValueConfirm; guiIntField.OnFocusLost += OnFieldValueConfirm; layout.AddElement(layoutIndex, guiIntField); } }
/// <inheritdoc/> protected override GUILayoutX CreateGUI(GUILayoutY layout) { GUILayoutX titleLayout = layout.AddLayoutX(); sizeField = new GUIIntField(new LocEdString(SeqIndex + ". ")); titleLayout.AddElement(sizeField); sizeField.OnChanged += x => { SetValue(x); MarkAsModified(); }; sizeField.OnFocusLost += ConfirmModify; sizeField.OnConfirmed += ConfirmModify; return(titleLayout); }
/// <summary> /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before /// use. /// </summary> /// <param name="parent">Animation window that this drop down window is a part of.</param> internal void Initialize(AnimationWindow parent) { GUIIntField fpsField = new GUIIntField(new LocEdString("FPS"), 40); fpsField.Value = parent.FPS; fpsField.OnChanged += x => { parent.FPS = x; }; GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX contentLayout = vertLayout.AddLayoutX(); contentLayout.AddFlexibleSpace(); contentLayout.AddElement(fpsField); contentLayout.AddFlexibleSpace(); vertLayout.AddFlexibleSpace(); }
/// <summary> /// Recreates all the GUI elements used by this inspector. /// </summary> private void BuildGUI() { Layout.Clear(); fontSizes = GUIArrayField <int, FontSizeArrayRow> .Create( new LocEdString("Font sizes"), importOptions.FontSizes, Layout); fontSizes.OnChanged += x => importOptions.FontSizes = x; fontSizes.IsExpanded = Persistent.GetBool("fontSizes_Expanded"); fontSizes.OnExpand += x => Persistent.SetBool("fontSizes_Expanded", x); charRanges = GUIArrayField <CharRange, CharRangeArrayRow> .Create( new LocEdString("Character ranges"), importOptions.CharRanges, Layout); charRanges.OnChanged += x => importOptions.CharRanges = x; charRanges.IsExpanded = Persistent.GetBool("charRanges_Expanded"); charRanges.OnExpand += x => Persistent.SetBool("charRanges_Expanded", x); renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode")); renderModeField.OnSelectionChanged += x => importOptions.RenderMode = (FontRenderMode)x; boldField = new GUIToggleField(new LocEdString("Bold")); boldField.OnChanged += x => importOptions.Bold = x; italicField = new GUIToggleField(new LocEdString("Italic")); italicField.OnChanged += x => importOptions.Italic = x; dpiField = new GUIIntField(new LocEdString("DPI")); dpiField.OnChanged += x => importOptions.DPI = x; reimportButton = new GUIButton(new LocEdString("Reimport")); reimportButton.OnClick += TriggerReimport; Layout.AddElement(renderModeField); Layout.AddElement(boldField); Layout.AddElement(italicField); Layout.AddElement(dpiField); Layout.AddSpace(10); GUILayout reimportButtonLayout = Layout.AddLayoutX(); reimportButtonLayout.AddFlexibleSpace(); reimportButtonLayout.AddElement(reimportButton); }
/// <inheritdoc/> protected internal override void Initialize(int layoutIndex) { if (property != null) { guiIntField = new GUIIntField(new GUIContent(title)); if (style != null) { if (style.StepStyle != null && style.StepStyle.Step != 0) { guiIntField.Step = (int)style.StepStyle.Step; } if (style.RangeStyle != null) { guiIntField.SetRange((int)style.RangeStyle.Min, (int)style.RangeStyle.Max); } } guiIntField.OnChanged += OnFieldValueChanged; guiIntField.OnConfirmed += OnFieldValueConfirm; guiIntField.OnFocusLost += OnFieldValueConfirm; layout.AddElement(layoutIndex, guiIntField); } }
/// <inheritdoc/> protected override GUILayoutX CreateGUI(GUILayoutY layout) { GUILayoutX titleLayout = layout.AddLayoutX(); rangeStartField = new GUIIntField(new LocEdString(SeqIndex + ". Start")); rangeEndField = new GUIIntField(new LocEdString("End")); titleLayout.AddElement(rangeStartField); titleLayout.AddElement(rangeEndField); rangeStartField.OnChanged += x => { CharRange range = GetValue <CharRange>(); range.start = x; SetValue(range); MarkAsModified(); }; rangeEndField.OnChanged += x => { CharRange range = GetValue <CharRange>(); range.end = x; SetValue(range); MarkAsModified(); }; rangeStartField.OnFocusLost += ConfirmModify; rangeStartField.OnConfirmed += ConfirmModify; rangeEndField.OnFocusLost += ConfirmModify; rangeEndField.OnConfirmed += ConfirmModify; return(titleLayout); }
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(); }
private static extern void Internal_CreateInstance(GUIIntField instance, ref GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
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; }
/// <inheritdoc/> protected override GUILayoutX CreateGUI(GUILayoutY layout) { AnimationSplitInfo rowSplitInfo = GetValue <AnimationSplitInfo>(); if (rowSplitInfo == null) { rowSplitInfo = new AnimationSplitInfo(); SetValue(rowSplitInfo); } GUILayoutX titleLayout = layout.AddLayoutX(); GUILayoutX contentLayout = layout.AddLayoutX(); GUILabel title = new GUILabel(new LocEdString(SeqIndex + ". ")); nameField = new GUITextField(new LocEdString("Name"), 40, false, "", GUIOption.FixedWidth(160)); startFrameField = new GUIIntField(new LocEdString("Start"), 40, "", GUIOption.FixedWidth(80)); endFrameField = new GUIIntField(new LocEdString("End"), 40, "", GUIOption.FixedWidth(80)); isAdditiveField = new GUIToggleField(new LocEdString("Is additive"), 50, "", GUIOption.FixedWidth(80)); startFrameField.SetRange(0, int.MaxValue); endFrameField.SetRange(0, int.MaxValue); titleLayout.AddElement(title); titleLayout.AddElement(nameField); titleLayout.AddFlexibleSpace(); contentLayout.AddSpace(10); contentLayout.AddElement(startFrameField); contentLayout.AddSpace(5); contentLayout.AddElement(endFrameField); contentLayout.AddSpace(5); contentLayout.AddElement(isAdditiveField); nameField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.name = x; MarkAsModified(); }; nameField.OnFocusLost += ConfirmModify; nameField.OnConfirmed += ConfirmModify; startFrameField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.startFrame = x; MarkAsModified(); }; startFrameField.OnFocusLost += ConfirmModify; startFrameField.OnConfirmed += ConfirmModify; endFrameField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.endFrame = x; MarkAsModified(); }; endFrameField.OnFocusLost += ConfirmModify; endFrameField.OnConfirmed += ConfirmModify; isAdditiveField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.isAdditive = x; MarkAsModified(); ConfirmModify(); }; return(titleLayout); }
/// <inheritdoc/> protected override GUILayoutX CreateGUI(GUILayoutY layout) { GUILayoutX titleLayout = layout.AddLayoutX(); sizeField = new GUIIntField(new LocEdString(SeqIndex + ". ")); titleLayout.AddElement(sizeField); sizeField.OnChanged += x => { SetValue(x); MarkAsModified(); }; sizeField.OnFocusLost += ConfirmModify; sizeField.OnConfirmed += ConfirmModify; return titleLayout; }
private static extern void Internal_CreateInstance(GUIIntField instance, GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
/// <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.As <Prefab>(); 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.TextureRef = winPlatformInfo.Icon; titleField.OnChanged += x => winPlatformInfo.TitleText = x; iconField.OnChanged += x => winPlatformInfo.Icon = x.As <Texture>(); } break; } }
/// <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> /// Creates a new rectangle offset GUI. /// </summary> /// <param name="title">Text to display on the title bar.</param> /// <param name="layout">Layout to append the GUI elements to.</param> public RectOffsetGUI(LocString title, GUILayout layout) { GUILayoutX rectLayout = layout.AddLayoutX(); rectLayout.AddElement(new GUILabel(title, GUIOption.FixedWidth(100))); GUILayoutY rectContentLayout = rectLayout.AddLayoutY(); GUILayoutX rectTopRow = rectContentLayout.AddLayoutX(); GUILayoutX rectBotRow = rectContentLayout.AddLayoutX(); offsetLeftField = new GUIIntField(new LocEdString("Left"), 40); offsetRightField = new GUIIntField(new LocEdString("Right"), 40); offsetTopField = new GUIIntField(new LocEdString("Top"), 40); offsetBottomField = new GUIIntField(new LocEdString("Bottom"), 40); rectTopRow.AddElement(offsetLeftField); rectTopRow.AddElement(offsetRightField); rectBotRow.AddElement(offsetTopField); rectBotRow.AddElement(offsetBottomField); offsetLeftField.OnChanged += x => { offset.left = x; if(OnChanged != null) OnChanged(offset); }; offsetRightField.OnChanged += x => { offset.right = x; if (OnChanged != null) OnChanged(offset); }; offsetTopField.OnChanged += x => { offset.top = x; if (OnChanged != null) OnChanged(offset); }; offsetBottomField.OnChanged += x => { offset.bottom = x; if (OnChanged != null) OnChanged(offset); }; Action DoOnConfirmed = () => { if (OnConfirmed != null) OnConfirmed(); }; offsetLeftField.OnConfirmed += DoOnConfirmed; offsetLeftField.OnFocusLost += DoOnConfirmed; offsetRightField.OnConfirmed += DoOnConfirmed; offsetRightField.OnFocusLost += DoOnConfirmed; offsetTopField.OnConfirmed += DoOnConfirmed; offsetTopField.OnFocusLost += DoOnConfirmed; offsetBottomField.OnConfirmed += DoOnConfirmed; offsetBottomField.OnFocusLost += DoOnConfirmed; }
/// <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 ? EditorStylesInternal.InspectorContentBgAlternate : EditorStylesInternal.InspectorContentBg; GUIToggle foldout = new GUIToggle(new LocEdString("Style"), EditorStyles.Foldout); foldout.AcceptsKeyFocus = false; 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.UUID); 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; }
/// <inheritdoc/> protected override GUILayoutX CreateGUI(GUILayoutY layout) { GUILayoutX titleLayout = layout.AddLayoutX(); rangeStartField = new GUIIntField(new LocEdString(SeqIndex + ". Start")); rangeEndField = new GUIIntField(new LocEdString("End")); titleLayout.AddElement(rangeStartField); titleLayout.AddElement(rangeEndField); rangeStartField.OnChanged += x => { CharRange range = GetValue<CharRange>(); range.start = x; SetValue(range); MarkAsModified(); }; rangeEndField.OnChanged += x => { CharRange range = GetValue<CharRange>(); range.end = x; SetValue(range); MarkAsModified(); }; rangeStartField.OnFocusLost += ConfirmModify; rangeStartField.OnConfirmed += ConfirmModify; rangeEndField.OnFocusLost += ConfirmModify; rangeEndField.OnConfirmed += ConfirmModify; return titleLayout; }
/// <summary> /// Creates a new rectangle offset GUI. /// </summary> /// <param name="title">Text to display on the title bar.</param> /// <param name="layout">Layout to append the GUI elements to.</param> public RectOffsetGUI(LocString title, GUILayout layout) { GUILayoutX rectLayout = layout.AddLayoutX(); rectLayout.AddElement(new GUILabel(title, GUIOption.FixedWidth(100))); GUILayoutY rectContentLayout = rectLayout.AddLayoutY(); GUILayoutX rectTopRow = rectContentLayout.AddLayoutX(); GUILayoutX rectBotRow = rectContentLayout.AddLayoutX(); offsetLeftField = new GUIIntField(new LocEdString("Left"), 40); offsetRightField = new GUIIntField(new LocEdString("Right"), 40); offsetTopField = new GUIIntField(new LocEdString("Top"), 40); offsetBottomField = new GUIIntField(new LocEdString("Bottom"), 40); rectTopRow.AddElement(offsetLeftField); rectTopRow.AddElement(offsetRightField); rectBotRow.AddElement(offsetTopField); rectBotRow.AddElement(offsetBottomField); offsetLeftField.OnChanged += x => { offset.left = x; if (OnChanged != null) { OnChanged(offset); } }; offsetRightField.OnChanged += x => { offset.right = x; if (OnChanged != null) { OnChanged(offset); } }; offsetTopField.OnChanged += x => { offset.top = x; if (OnChanged != null) { OnChanged(offset); } }; offsetBottomField.OnChanged += x => { offset.bottom = x; if (OnChanged != null) { OnChanged(offset); } }; Action DoOnConfirmed = () => { if (OnConfirmed != null) { OnConfirmed(); } }; offsetLeftField.OnConfirmed += DoOnConfirmed; offsetLeftField.OnFocusLost += DoOnConfirmed; offsetRightField.OnConfirmed += DoOnConfirmed; offsetRightField.OnFocusLost += DoOnConfirmed; offsetTopField.OnConfirmed += DoOnConfirmed; offsetTopField.OnFocusLost += DoOnConfirmed; offsetBottomField.OnConfirmed += DoOnConfirmed; offsetBottomField.OnFocusLost += DoOnConfirmed; }
/// <summary> /// Recreates all the GUI elements used by this inspector. /// </summary> private void BuildGUI() { Layout.Clear(); fontSizes = GUIArrayField<int, FontSizeArrayRow>.Create( new LocEdString("Font sizes"), importOptions.FontSizes, Layout); fontSizes.OnChanged += x => importOptions.FontSizes = x; fontSizes.IsExpanded = Persistent.GetBool("fontSizes_Expanded"); fontSizes.OnExpand += x => Persistent.SetBool("fontSizes_Expanded", x); charRanges = GUIArrayField<CharRange, CharRangeArrayRow>.Create( new LocEdString("Character ranges"), importOptions.CharRanges, Layout); charRanges.OnChanged += x => importOptions.CharRanges = x; charRanges.IsExpanded = Persistent.GetBool("charRanges_Expanded"); charRanges.OnExpand += x => Persistent.SetBool("charRanges_Expanded", x); renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode")); renderModeField.OnSelectionChanged += x => importOptions.RenderMode = (FontRenderMode)x; boldField = new GUIToggleField(new LocEdString("Bold")); boldField.OnChanged += x => importOptions.Bold = x; italicField = new GUIToggleField(new LocEdString("Italic")); italicField.OnChanged += x => importOptions.Italic = x; dpiField = new GUIIntField(new LocEdString("DPI")); dpiField.OnChanged += x => importOptions.DPI = x; reimportButton = new GUIButton(new LocEdString("Reimport")); reimportButton.OnClick += TriggerReimport; Layout.AddElement(renderModeField); Layout.AddElement(boldField); Layout.AddElement(italicField); Layout.AddElement(dpiField); Layout.AddSpace(10); GUILayout reimportButtonLayout = Layout.AddLayoutX(); reimportButtonLayout.AddFlexibleSpace(); reimportButtonLayout.AddElement(reimportButton); }
/// <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(); }
/// <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; } }
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(EditorStyles.ColorSliderVert); guiSliderRHorz = new GUISliderH(EditorStyles.ColorSliderHorz); guiSliderGHorz = new GUISliderH(EditorStyles.ColorSliderHorz); guiSliderBHorz = new GUISliderH(EditorStyles.ColorSliderHorz); guiSliderAHorz = new GUISliderH(EditorStyles.ColorSliderHorz); guiSlider2DHandle = new GUITexture(null, EditorStyles.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> /// Rebuilds the GUI list header if needed. /// </summary> protected void UpdateHeaderGUI() { Action BuildEmptyGUI = () => { guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); guiInternalTitleLayout.AddElement(new GUILabel(title)); guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100))); GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create), new LocEdString("Create")); GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30)); createBtn.OnClick += OnCreateButtonClicked; guiInternalTitleLayout.AddElement(createBtn); }; Action BuildFilledGUI = () => { guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout); guiFoldout.Value = isExpanded; guiFoldout.OnToggled += ToggleFoldout; guiSizeField = new GUIIntField("", GUIOption.FixedWidth(50)); guiSizeField.SetRange(0, int.MaxValue); GUIContent resizeIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Resize), new LocEdString("Resize")); GUIButton guiResizeBtn = new GUIButton(resizeIcon, GUIOption.FixedWidth(30)); guiResizeBtn.OnClick += OnResizeButtonClicked; GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear), new LocEdString("Clear")); GUIButton guiClearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(30)); guiClearBtn.OnClick += OnClearButtonClicked; guiInternalTitleLayout.AddElement(guiFoldout); guiInternalTitleLayout.AddElement(guiSizeField); guiInternalTitleLayout.AddElement(guiResizeBtn); guiInternalTitleLayout.AddElement(guiClearBtn); guiSizeField.Value = GetNumRows(); guiChildLayout = guiLayout.AddLayoutX(); guiChildLayout.AddSpace(IndentAmount); guiChildLayout.Active = isExpanded; GUIPanel guiContentPanel = guiChildLayout.AddPanel(); GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX(); guiIndentLayoutX.AddSpace(IndentAmount); GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiContentLayout = guiIndentLayoutY.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiIndentLayoutX.AddSpace(IndentAmount); guiChildLayout.AddSpace(IndentAmount); short backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1); string bgPanelStyle = depth % 2 == 0 ? EditorStyles.InspectorContentBgAlternate : EditorStyles.InspectorContentBg; GUIPanel backgroundPanel = guiContentPanel.AddPanel(backgroundDepth); GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle); backgroundPanel.AddElement(inspectorContentBg); }; if (state == State.None) { if (!IsNull()) { BuildFilledGUI(); state = State.Filled; } else { BuildEmptyGUI(); state = State.Empty; } } else if (state == State.Empty) { if (!IsNull()) { guiInternalTitleLayout.Destroy(); BuildFilledGUI(); state = State.Filled; } } else if (state == State.Filled) { if (IsNull()) { guiInternalTitleLayout.Destroy(); guiChildLayout.Destroy(); BuildEmptyGUI(); state = State.Empty; } } }
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(); }