using UnityEngine; using UnityEditor; using UnityEngine.UI; public class ButtonHelper : Editor { [MenuItem("CONTEXT/Button/Set Template Colors")] static void SetColors(MenuCommand command) { Button button = (Button)command.context; // Convert hexadecimal color value to Color object ColorUtility.TryParseHtmlString("#51838E", out Color NormalColor); ColorUtility.TryParseHtmlString("#9FBEB8", out Color HighlightedColor); ColorUtility.TryParseHtmlString("#9FBEB8", out Color PressedColor); ColorUtility.TryParseHtmlString("#C8C8C8", out Color DisabledColor); // Set the colors button.colors = new ColorBlock { normalColor = NormalColor, highlightedColor = HighlightedColor, pressedColor = PressedColor, selectedColor = PressedColor, disabledColor = DisabledColor, colorMultiplier = 1, fadeDuration = 0.1f }; EditorUtility.SetDirty(button); } }