public GUIAnimFieldEntry(GUIAnimFieldLayouts layouts, string path, bool child, int indentAmount) { this.path = path; GUILayoutX toggleLayout = layouts.main.AddLayoutX(); toggleLayout.AddSpace(indentAmount); selectionBtn = new GUIButton(GetDisplayName(path, child), EditorStyles.Label, GUIOption.FlexibleWidth()); selectionBtn.OnClick += () => { OnEntrySelected?.Invoke(path); }; toggleLayout.AddElement(selectionBtn); entryHeight = selectionBtn.Bounds.height; backgroundTexture = new GUITexture(Builtin.WhiteTexture, GUITextureScaleMode.StretchToFit, GUIOption.FlexibleWidth()); backgroundTexture.SetTint(Color.Transparent); backgroundTexture.SetHeight(entryHeight); layouts.background.AddElement(backgroundTexture); }
private void OnInitialize() { guiOK = new GUIButton(new LocEdString("OK")); guiCancel = new GUIButton(new LocEdString("Cancel")); guiOK.OnClick += OnOK; guiCancel.OnClick += OnCancel; GUILayout mainVertLayout = GUI.AddLayoutY(); mainVertLayout.AddSpace(10); GUILayout editorHorzLayout = mainVertLayout.AddLayoutX(); editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING); GUIPanel gradientEditorPanel = editorHorzLayout.AddPanel(); editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING); mainVertLayout.AddSpace(15); GUILayout buttonHorzLayout = mainVertLayout.AddLayoutX(); buttonHorzLayout.AddFlexibleSpace(); buttonHorzLayout.AddElement(guiOK); buttonHorzLayout.AddSpace(10); buttonHorzLayout.AddElement(guiCancel); buttonHorzLayout.AddFlexibleSpace(); mainVertLayout.AddFlexibleSpace(); editorPanel = gradientEditorPanel.AddPanel(0); GUIPanel editorOverlay = gradientEditorPanel.AddPanel(-1); overlayCanvas = new GUICanvas(); editorOverlay.AddElement(overlayCanvas); GUILayout editorVertLayout = editorPanel.AddLayoutY(); GUILayout guiGradientLayout = editorVertLayout.AddLayoutX(); guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2); texture = Texture.Create2D(TEX_WIDTH, TEX_HEIGHT); spriteTexture = new SpriteTexture(texture); guiGradientTexture = new GUITexture(spriteTexture, GUITextureScaleMode.StretchToFit); guiGradientTexture.SetHeight(30); UpdateTexture(); guiGradientLayout.AddElement(guiGradientTexture); guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2); editorVertLayout.AddSpace(10); editor = new GradientKeyEditor(editorVertLayout, gradient.GetKeys(), Width - EDITOR_HORZ_PADDING * 2, 20); editor.OnGradientModified += colorGradient => { gradient = colorGradient; UpdateTexture(); UpdateKeyLines(); }; editorVertLayout.AddFlexibleSpace(); GUITexture containerBg = new GUITexture(null, EditorStylesInternal.ContainerBg); Rect2I containerBounds = editor.GetBounds(GUI); containerBounds.x -= 2; containerBounds.y -= 2; containerBounds.width += 4; containerBounds.height += 6; containerBg.Bounds = containerBounds; GUIPanel editorUnderlay = GUI.AddPanel(1); editorUnderlay.AddElement(containerBg); UpdateKeyLines(); EditorInput.OnPointerPressed += OnPointerPressed; EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked; EditorInput.OnPointerMoved += OnPointerMoved; EditorInput.OnPointerReleased += OnPointerReleased; EditorInput.OnButtonUp += OnButtonUp; }