Hi dudes, i want to create a button with round corners and with a white border. I dont want to use *.png because i want to change the filled color with a script. (single point of control) How is that possible? any ideas?
You can't be honest in the modern world, just be careful that other don't know about your dirty things (and the UI is looking ok on different sizes)
hahahaha thank you for your support - if there is no other method for success i have no choice. But i feel like balrog vs gandalf (unity) "you shall not pass!"
Make a white button png texture with rounded corners and transparent background, use the Image component's 9-slicing feature to preserve the corners for resizing. Use the color field on the Image component to tint the button different colors. That is how the default unity button image works. Then apply a white colored square behind it as mentioned previously for the border. There are more complex ways to do this with shaders, but you don't need to do that. A simple 2 Image setup works. If you wanted it to feel more like one thing, give the parent object a script to control both child image colors, so you have one point of control with two color fields. Code (CSharp): using UnityEngine; using UnityEngine.UI; public class MyButton : MonoBehaviour { [Header("Button")] public Image button; public Color buttonColor; [Header("Background")] public Image background; public Color backgroundColor; private void OnValidate() { if(button != null) { button.color = buttonColor; } if(background != null) { background.color = backgroundColor; } } } You could even extend the Button class with new fields for a background image if you wanted.