Create a custom button
Hello,
I'm pretty new with Unity, I guess this question has been asked thousands of times but I can't find the answer...
I find the UI.Button limited in options, I'd like to add 2 targets in the color tint to be able to change the colors for both my button and its text (different set of colors). I understood that the best way would be to extend the UI.Button or create a new button. I don't want to use Animation because I want to keep my colors in the same file for the whole project (StylesController), and I didn't find the way to link my StylesController to the Animation.
This is how I set my colors in the awake method of my button :
public Styles StylesReference;
public Button button;
public Text buttonText;
private void Awake()
{
//Button's colors
ColorBlock cb = this.button.colors;
cb.normalColor = StylesReference.ColorButtonNormal;
cb.highlightedColor = StylesReference.ColorButtonHover;
cb.disabledColor = StylesReference.ColorButtonDisabled;
cb.pressedColor = StylesReference.ColorButtonPressed;
this.button.colors = cb;
// Color's of the text
}
Color tint is selected with my button's image as a target. But doing it this way I can't set the color for the text for pressed/hovered/disabled states.
Please stop me if my approach is wrong, my idea was to be able to have only one file for the colors and all the components (buttons, panels, checkboxes ...) would automatically have the latest colors and I would thus be able to change my whole application's colors in 5 minutes.
But so far I've haven't been able to add several color tint targets, how would you do it ?
I hope my question is clear enough to be understood.
Thank you very much,
Your answer

Follow this Question
Related Questions
AutoClick UI Button 0 Answers
How do I make a UI Buttion play an Animation when pressed? 0 Answers
Unity Button to switch Bool 1 Answer
AddListener not working after build 0 Answers
Queue emptying by itself 0 Answers