private void AddSwatch(Color32 color) { SwatchButton button = swatchesPanel.AddUIComponent <SwatchButton>(); button.Build(color); button.EventSwatchClicked += OnSwatchClicked; }
public void Build(PanelType panelType, Layout layout, SavedSwatch savedSwatch) { base.Build(panelType, layout); this.savedSwatch = savedSwatch; swatchButton = AddUIComponent <SwatchButton>(); swatchButton.Build(savedSwatch.Color); textField = AddUIComponent <UITextField>(); textField.normalBgSprite = ""; textField.hoveredBgSprite = "ButtonSmallHovered"; textField.focusedBgSprite = "ButtonSmallHovered"; textField.size = new Vector2(187.0f, 19.0f); textField.font = UIUtil.Font; textField.textScale = 1f; textField.verticalAlignment = UIVerticalAlignment.Middle; textField.horizontalAlignment = UIHorizontalAlignment.Left; textField.padding = new RectOffset(5, 0, 3, 3); textField.builtinKeyNavigation = true; textField.isInteractive = true; textField.readOnly = false; textField.selectionSprite = "EmptySprite"; textField.selectOnFocus = true; textField.text = savedSwatch.Name; textField.atlas = Resources.DefaultAtlas; deleteButton = AddUIComponent <UIButton>(); deleteButton.normalBgSprite = ""; deleteButton.hoveredBgSprite = "DeleteLineButtonHover"; deleteButton.pressedBgSprite = "DeleteLineButtonPressed"; deleteButton.size = new Vector2(19.0f, 19.0f); deleteButton.atlas = Resources.DefaultAtlas; swatchButton.EventSwatchClicked += OnSwatchClicked; textField.eventTextChanged += OnTextChanged; deleteButton.eventClicked += OnDeleteClicked; deleteButton.eventMouseEnter += OnMouseEnter; deleteButton.eventMouseLeave += OnMouseLeave; eventMouseEnter += OnMouseEnter; eventMouseLeave += OnMouseLeave; }