Change Unity GUI.Box text colour - user-interface

I am kind of new to Unity, and was just wondering how to change the text colour of a GUI.Box?
This is the line of code I am using:
GUI.Box(Rect(0, 0, width, height),"Hello World", "");
I tried putting:
GUI.color = Color.red;
above it, but that didn't work.
Thanks,
Fjpackard.

GUI.skin.box.normal.textColor = Color.red;
Perhaps a better way is take a look at GUIStyles (http://docs.unity3d.com/Documentation/Components/class-GUIStyle.html) since GUIStyle is an easy way to modify the appearance of the whole GUI.

In some cases you may want to change only a specific word or sentence, so you just need to make your text like that:
sb.Append("<size=10> <color=yellow>WARNING: </color> Some text here</size>");
In this case my style font size is 8, so this text will be a bit bigger then the other lines, the word WARNING will be written in yellow and 'Some text here' is the default color. All the other text inside my string builder will use the Box Style
For more details check:
https://docs.unity3d.com/Manual/StyledText.html

Related

Force change label text colour

I have the following codepen: https://codepen.io/conormdowney/pen/dwmpKQ
Is there a way to force the text of the label at the top of the bars to change colour. If I wanted it to be Red for example.
I tried the below but it doesnt do anything
valueLabel.label.fill = am4core.color("#567");
also tried
valueLabel.label.text.fill = am4core.color("#567");

How to center-align text in Scintilla?

In my application I have a custom control that implements syntax highlighting via the scintilla.dll.
There are all sorts of codes for setting the style of the text in the control.
However, I've searched and searched and can't figure out how to center-align text in the control.
What's the scintilla code for center-aligning a text style?
There is no "center-align" command in scintilla.
Here is what to do, however, to center the text:
Fetch the text from the control
Know what style is being used
Use TEXTWIDTH (2276) to figure the width of the text using that style
Use controlwidth /2 - textwidth /2 to figure the location of the left margin
Use SETMARGINLEFT (2155) to move the left margin
Note that the default style is 32.
You'll have to figure your code to update the location every time, however, maybe via some callback function.
In Autohotkey, it could look like this:
guicontrolget, editor
guicontrolget, editor, pos
textwidth := hwndeditor.2276(32,editor)
setplace := (editorW /2) - textwidth /2
hpeditor.2155(0,setplace)

How can I change item or image color in tabBar swift?

I want to change item color in tabBar, not text the items not selected etc Longtime aim searching about it, I didn't find. I just found this code, it does not change item or image color, just text.
The default color is grey, I want to change it.
This is the code I found:
UITabBar.appearance().barTintColor = UIColor(redRGB: 93, greenRGB: 175, blueRGB: 228)
UITabBar.appearance().tintColor = UIColor .redColor()
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor()], forState:.Normal)
Try google for searching. No seriously try it.
For your problem. What is gray? UITabbaritems are standard grayed out in storyboard.
You can use
var image : UIImage? = UIImage(named:"myImage.png").imageWithRenderingMode(.AlwaysOriginal)
The option Always original keeps the image as it is and it will not be grayed out.
For problems with that => Rendering always original problems

How to align text to the top of the button in Matlab GUI?

I have a GUI with big buttons and wouls like to align the text in the button to the top, all I found is "horizontal alignment" property.
Thanks...
You need to access the underlying Java Swing component (I am using FINDJOBJ function):
figure('Menubar','none', 'Position',[200 200 300 200])
h = uicontrol('Style','pushbutton', 'String','click', ...
'Units','normalized', 'Position',[0.3 0.3 0.5 0.5]);
jh = findjobj(h);
jh.setVerticalAlignment( javax.swing.AbstractButton.BOTTOM );
I'm afraid I think you can't do this - text is always vertically aligned at the middle on a uicontrol. The only hacks I can think of that might achieve something like what you want are
Add extra return characters after your main text, so that the real text ends up at the top while the whole text remains centred
(REALLY horrible) Create an image with your text right at the top, and use this with the CData property of the button.

disable text selection in gwt

i am pretty new to GWT,
i have an image that i have placed a text on top, i need the text to look as part of the image.
i have used the image widget and the HTML widget to position it on top of it, i need this text to change according the locale.
the problem that the text is selectable, so it does not look right.
1) is there any way to make the text un-selectable?
2) is there a better way to achieve that?
thanks
This is handled by the user-select attribute.
See: http://www.tek-tips.com/viewthread.cfm?qid=1184318&page=1

Resources