private void SignButton(ButtonBoardCell button) { button.SetIcon(SignIcon); button.SetColor(StyleManager.Text); button.OnClick += () => { ButtonToggleActive(button); }; button.OnActiveChanged += (active) => { if (OnSignButtonChange != null) { OnSignButtonChange(active); } if (!active) { return; } SignBoard signBoard = InitChildSignBoard(); signBoard.OnInputChanged = OnSignInputChanged; signBoard.OnValidate = OnSignInputValidate; if (OnSignDefault != null) { signBoard.SetSign(OnSignDefault()); } }; }
public void InitButtons() { int count = CountOfButtons != null?CountOfButtons() : 0; btns = new ButtonBoardCell[count]; float width = UIConstants.ElementBottonWidth; // float height = UIConstants.ElementBottonHeight; for (int i = 0; i < count; i++) { GameObject buttonObject = GameObject.Instantiate(ButtonPrefab.gameObject); buttonObject.transform.SetParent(btnWrap.transform, false); ButtonBoardCell button = buttonObject.GetComponent <ButtonBoardCell>(); button.Init(); float posX = UIConstants.ElementBottonWidth * i; button.SetPosXAndWidth(posX, width); // rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, posX, width); // // rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, height); ButtonAtIndex(button, i); btns[i] = button; } buttonsWidth = UIConstants.ElementBottonWidth * count; rectTransform.sizeDelta = new Vector2(buttonsWidth, UIConstants.ElementBottonHeight); }
private void CoordinateButton(ButtonBoardCell button) { button.SetIcon(CoordinateIcon); button.SetColor(StyleManager.Text); button.OnClick += () => { if (OnElementClickCoordinate != null) { OnElementClickCoordinate(); } }; }
private void ButtonAtStyleBoard(ButtonBoardCell rootButton, ButtonBoardCell button, int buttonIndex) { button.SetIcon(StyleOfIndex(buttonIndex).Icon); button.SetColor(ColorOfIndex(0)); button.OnClick += () => { rootButton.SetIcon(StyleOfIndex(buttonIndex).Icon); if (OnElementClickStyle != null) { OnElementClickStyle(element, buttonIndex); } }; }
private void ButtonAtColorBoard(ButtonBoardCell rootButton, ButtonBoardCell button, int buttonIndex) { button.SetIcon(null); Color color = ColorOfIndex(buttonIndex); button.SetColor(color); button.OnClick += () => { rootButton.SetColor(color); if (OnElementClickColor != null) { OnElementClickColor(element, buttonIndex); } }; }
private void DisplayButton(ButtonBoardCell button) { bool visible = OnElementVisible(); button.SetIcon(visible ? ShowIcon : HideIcon); button.SetColor(StyleManager.Text); button.OnClick += () => { if (OnElementClickDisplay != null) { OnElementClickDisplay(!visible); } visible = OnElementVisible(); button.SetIcon(visible ? ShowIcon : HideIcon); }; }
private void ButtonToggleActive(ButtonBoardCell button) { bool isActive = button.IsActive(); if (activeRootButton) { activeRootButton.SetActive(false); } if (childBoard) { Destroy(childBoard); } activeRootButton = null; if (!isActive) { button.SetActive(true); activeRootButton = button; } }
private void StyleButton(ButtonBoardCell button) { button.SetIcon(StyleOfIndex(element.style).Icon); button.SetColor(ColorOfIndex(0)); button.OnClick += () => { ButtonToggleActive(button); }; button.OnActiveChanged += (active) => { if (!active) { return; } ButtonBoard styleBoard = InitChildButtonBoard(); styleBoard.CountOfButtons = () => ElementStyle(element).Count; styleBoard.ButtonAtIndex = (childButton, index) => ButtonAtStyleBoard(button, childButton, index); styleBoard.InitButtons(); }; }
private void ColorButton(ButtonBoardCell button) { button.SetIcon(null); button.SetColor(ColorOfIndex(element.color)); button.OnClick += () => { ButtonToggleActive(button); }; button.OnActiveChanged += (active) => { if (!active) { return; } ButtonBoard colorBoard = InitChildButtonBoard(); colorBoard.CountOfButtons = () => StyleManager.Themes.Length + 1; colorBoard.ButtonAtIndex = (childButton, index) => ButtonAtColorBoard(button, childButton, index); colorBoard.InitButtons(); }; }