Change the border's color of a button in Unity3D - unity3d

I began to work with Unity3D since one month and I'm trying to do an application which contains a menu, composed by a panel and several buttons. At this moment, I'm trying to customize the menu, I change the fill color of the panel and buttons, but until now I could not change the border color of the buttons. There is any way to customize the border's color of the UI buttons? I would appreciate your help. :)

The easiest way to add an outline to your button is to use the Outline component (doc).
Simply add the Outline component where your button image or text is. Then configure it how you like it :)
The above results in the following button:

No, you can not change just border color. If you use default buttons, take a look at Source image. It is basically a grey square with black borders. So when you change color of image black color remains black.
To customize buttons as you want you need either create nested UI elements:
or create sprites with colors you want and replace source image

I find nested UI elements to be the easiest way to do something like this. Simple example:
Start out by creating a panel and change the scale until you get the desired size for your button. This will be your "borders".
Next create another panel as a child of the panel you just made and change the scale to be just slightly smaller than your first panel and change the color.
In the Inspector for your panel, add component and type in Button and add it as a component.
Finally, add a text as a child of your panel for a label and you're done.

Related

Fill letter with different color in certain direction

I need to create such animation in Flutter, in which by clicking on the letter(it can be svg, or ttf) it will fill with color in specific direction.
So, for example:
By clicking in letter, it should somehow be filled with color(let's say red), staring from top to bottom.
How it possible to do programmatically?
Have a look at the package: https://pub.dev/packages/animated_text_kit.
It provides Colorize and LiquidTextFill which can be used to achieve what you need.

How do I make these GTK buttons that are drawn together in a group?

GTK has a way to draw a group of buttons together so they look like one big button with a divider between them, rather than buttons that are drawn apart. It's useful for drawing buttons together that have a similar function.
Here's an example from the GTK inspector, where they appear to be specifically toggle buttons where only one can be selected:
Another example, from Glade, where each button represents a category of widgets and opens a menu:
What is this style of buttons called, and how do I make them?
GTK Inspector example shows GtkStackSwitcher, a special widget used to control the GtkStack (for page switching).
Generally, to achieve this visual effect for a group of buttons, GtkButtonBox is used with the layout style set to GTK_BUTTONBOX_EXPAND.
Buttons expand to fill the box. This entails giving buttons a "linked" appearance, making button sizes homogeneous, and setting spacing to 0
You can also manually add a "linked" style to any container with buttons:
GtkStyleContext *context;
...
context = gtk_widget_get_style_context(button_box);
gtk_style_context_add_class(context, GTK_STYLE_CLASS_LINKED);
HowDoI/Buttons (paragraph "Linked buttons")

TextMeshPro Text Overlaps Icon

I have my highscore, when it changes it moves to the left, but i need to move it to the right.
How i could achieve that?
Here is problem in imgur picture
I'm using canvas with TextMesPro Text and icon as image
TextMesPro
Put the text and the icon inside a HorizontalLayoutGroup and add a LayoutElement to both. Set the HorizontalLayoutGroup to control child height/width, child force expand width/height. Set the flexible width to the text (in the LayoutElement) to a very high value. Set the preferred size of the image to the size you want the icon to be. You might also want to add a little bit of spacing to the layout group.

iOS - Interface Builder: UIButton title disappears when setting image

I have made a project previously where I set a UIButton to have both text and also an image (in interface builder).
I have created another project and I want to achieve the same thing, but when I set the button to have an image, the title disappears (it's not getting hidden behind the image).
I can't seem to figure out why this is so if anyone could shed some light on this subject I'd appreciate it!
Thanks.
Change your button to custom type. put the image on then put the text in.
You will need to put your own background on it, but at that point you will be able to use the edge settings to position both the text and the image.
Every button that I have with image and text is set to custom and ultimately has its own bg image as well.
Oh, another thing I use. Is the cornerRadius. To give the view the rounded effect like the buttons have by default.
saveButton.layer.cornerRadius = roundingNumber.floatValue;
Additionally you should be able to use the borderWidth and borderColor in conjunction with cornerRadius to get a button that looks quite similar to the original button
saveButton.layer.borderRadius = 1.0f;
saveButton.layer.borderColor = [[UIColor blueColor] CGColor];
// These are not the exact values (or maybe they are) but you get the idea.
hope that helps.
Correction
After Spending a little time investigating, it appears that when you put an image in the button. the text is shoved off to the right.
Use the edge settings to bring it back over the image.
With the button selected, Look in "Attributes Inspector" > Button > Edge > (Dropdown "Title")
the equasion I have come up with is
[Edge inset for Title] Left = -(imageWidth * 2)
This should Left align your title with the image that you have put in.
Custom positioning will need to be done to make it look correct.
This can be done entirely in the Interface Builder and you can use RoundedRect button style
Here are some images demonstrating the change.
Here I set the Button type to "Custom" to remove the border and background.
Here I set the Top and Left in the Edge set for "Title" (Title is an option in the drop down)
EDIT
Newest Xcode has moved the size settings to a new location
Just put the image in the background field instead. This way the text will appear in front of the image.
It sounds like you are setting the image for the button but not the background image so reverse that.
I noticed that if the UIButton colour is set to default, adding an image makes it white and thus invisible. Changing the colour manually makes it visible again.

Starling Feathers Extend Theme - Custom button

I am trying to work out how to use a sprite added to a themes sprite sheet as a button but not having much luck.
I have created the entire button with click state and label and added to the theme sprite sheet and need to use on a button. I have a number of custom buttons I would like to use but I would also like to use a number of the theme skin (Minimal skin).
I have looked at the extending themes section but unsure how to use a signal sprite image for 1 button, another for another button and the theme skin for others.
Cheers
Look at the names property, this is how the theme "knows" what initializer function to call