Jump to content

[ANSWERED] How to change text color and insert special symbols?


Recommended Posts

There definitely must be the way to change text color and insert a science or a funds symbols into a plain text, e.g. how it is done in research nodes tooltips. I'm almost sure that it is not a texture but a some special symbol that is treated by the KSP font as a science sign. As for the text color, it should be changed with some #ff00ff pattern but I can't figure out how to enable it (<html> and tags do not work).

Does anyone know a way to do it or a mod that alters the text of tooltips using color and special symbols?

Edited by Ser
Link to comment
Share on other sites

There definitely must be the way to change text color and insert a science or a funds symbols into a plain text, e.g. how it is done in research nodes tooltips. I'm almost sure that it is not a texture but a some special symbol that is treated by the KSP font as a science sign. As for the text color, it should be changed with some #ff00ff pattern but I can't figure out how to enable it (<html> and tags do not work).

Does anyone know the way to do it or a mod that alters text of tooltips using color and special symbols?

I think :

<color=#ff00ff>TEXT</color>

You can also set size with :

<size=15>TEXT</size>

In most cases you can also write '£' to write the fund symbol. I don't know for science symbol (I'll update this post if I find a way)

[EDIT]

Here are all text style possibilities : http://docs.unity3d.com/Manual/StyledText.html

[EDIT 2]

Try this :


Funds sign : £
Science sign : © (copyright sign)
reputation sign : ¡ (inverted exclamation sign ?)

[EDIT 3]

That seems not to work... Sorry :(

Edited by simon56modder
Link to comment
Share on other sites

Thanks a lot. In my case special symbols work. Rich text tags don't but at least they are not printed to output. Seems to be the RichText is disabled on that element, have no idea how to enable it but got some clues now.

Link to comment
Share on other sites

This is for a regular string, something that would go in a GUI.Label? I seem to remember this not working for ScreenMessages, but for regular strings this should work:


"<color=\"" + hexCode + "\">" + text + "</color>"

Note the additional "" around the hex code. This is what SCANsat uses and it seems to work fine.

Link to comment
Share on other sites

But still doesn't work for me.

Where do you want to color your text ? (so what type of text is it) Maybe it helps ;)

I know DMagic's code works with GUI.Label but perhaps it doesn't in your case ...

Edited by simon56modder
Link to comment
Share on other sites

Where do you want to color your text ? (so what type of text is it) Maybe it helps ;)

I know DMagic's code works with GUI.Label but perhaps it doesn't in your case ...

Yes, the things you both have advised worked fine for GUI.Label (the color, not the special symbols - strange). But my final goal is to change text of a tooltip that shows up at Research and Development when you hover the mouse over a tree node (you know, it says "Researched" in green, or "*5" in blue, or "The node doesn't meet requirements" in orange).

What can I do at the moment is only a white text in the tooltip that distracts the original look a little. I tried to list all of its transform's children but it gave me nothing useful.

Edited by Ser
Link to comment
Share on other sites

Hmmm... Last idea I saw in the code :

[#ff00ff]TEXT

And what about my old method but with caps ?

<#FF00FF>TEXT</>

I found this on Unity forums, maybe you'll find answers :

http://forum.unity3d.com/threads/cant-seem-to-get-rich-text-to-work-in-ui-text.268105/#post-1786263

Edited by simon56modder
Link to comment
Share on other sites

Yes, the things you both have advised worked fine for GUI.Label (the color, not the special symbols - strange). But my final goal is to change text of a tooltip that shows up at Research and Development when you hover the mouse over a tree node (you know, it says "Researched" in green, or "*5" in blue, or "The node doesn't meet requirements" in orange).

What can I do at the moment is only a white text in the tooltip that distracts the original look a little. I tried to list all of its transform's children but it gave me nothing useful.

AFAIK those don't uses the legacy Unity UI so they won't use the same system for rich text (if they allow any)

Link to comment
Share on other sites

Both methods don't work. The "[...]"tags are printed as they are and that means they are wrong. But the "<..>" doesn't get into the output so it seems to be the right syntax. Only the right tag is needed to be found.

I've already seen the link suggested by simon56modder. The problem is the tooltip I'm dealing with doesn't have a text as a child. guiText property is null as well. After realizing that I've printed all its children and there was nothing but arrows. It's because this tooltip is not a unity standard one, it has the type Tooltips.TooltipController_Dynamic. How the crap do they make it change its text color...

Edited by Ser
Link to comment
Share on other sites

Those are EZGUI components. The doc says to use [#...]. But the KSP code seems to use "<#f97306>©OrangeText</>" ...

Exactly! I've copied your text as it is and voi la, it's orange. But simon56modder suggested the same thing, I must have messed up some concats that time.

Thanks for your time and help, guys. Hope my new mod will be interesting for you too when I deliver it.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...