/// <summary> /// Create the basic UI unselectable button. /// </summary> /// <remarks> /// Hierarchy: /// (root) /// UnselectableButton /// -Text /// </remarks> /// <param name="resources">The resources to use for creation.</param> /// <returns>The root GameObject of the created element.</returns> public static GameObject CreateUnselectableButton(Resources resources) { GameObject buttonRoot = CreateUIElementRoot("UnselectableButton", s_ThickElementSize, typeof(Image), typeof(UnselectableButton)); GameObject childText = CreateUIObject("Text", buttonRoot, typeof(Text)); Image image = buttonRoot.GetComponent <Image>(); image.sprite = resources.standard; image.type = Image.Type.Sliced; image.color = s_DefaultSelectableColor; UnselectableButton bt = buttonRoot.GetComponent <UnselectableButton>(); SetDefaultColorTransitionValues(bt); Text text = childText.GetComponent <Text>(); text.text = "Unselectable Button"; text.alignment = TextAnchor.MiddleCenter; SetDefaultTextValues(text); RectTransform textRectTransform = childText.GetComponent <RectTransform>(); textRectTransform.anchorMin = Vector2.zero; textRectTransform.anchorMax = Vector2.one; textRectTransform.sizeDelta = Vector2.zero; return(buttonRoot); }
private void ChangeParametr_Click(object sender, EventArgs e) { if (sender is UnselectableButton button) { if (_actionButton != null) { _actionButton.BackColor = BackColor; } if (_actionButton != button) { _actionButton = button; _actionButton.BackColor = Color.YellowGreen; SetSelectValue(); } else { _actionButton = null; return; } } }