Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Rabagast on May 23, 2017, 04:42:21 AM

Title: Set color on a specific character of a text
Post by: Rabagast on May 23, 2017, 04:42:21 AM
Is it possible to set a color on a specific character of a text? For example, I have Player 1 score like this: "PL1 0" and I use build string when I add the score. But the first 3 letters "PL1", should be white and the score should be green. Is this possible?
Title: Re: Set color on a specific character of a text
Post by: edufurla on May 23, 2017, 04:50:30 AM
With Text Mesh Pro is easy. You can write a code before each caracter to change color, size, etc... See the help for the codes avaliable.
Good luck
Title: Re: Set color on a specific character of a text
Post by: tcmeric on May 23, 2017, 07:59:46 AM
Also textmesh pro now has playmaker actions.

https://github.com/dumbgamedev/TextMeshPro_Playmaker
Title: Re: Set color on a specific character of a text
Post by: Rabagast on May 23, 2017, 04:20:03 PM
Hi!
Thanks for the answer both of you. I used Text Mesh Pro, but before the Actions were released. I used Get and Set Properties, but it's a lot easer with those Actions.
It should be in the Ecosystem. Or at least download the whole package in one file.

Have you tried the Text Mesh Pro Actions? Does it works great, without any bugs?
Title: Re: Set color on a specific character of a text
Post by: Rabagast on May 23, 2017, 05:11:08 PM
 downloaded them all, but I get a lot of errors. So I deleted them all and imported only "GetTextMeshProText.cs" And I still get errors.
Here are two errors I get:

Assets/PlayMaker Custom Actions/TextMeshPro/getTextmeshProText.cs(7,0): error CS1525: Unexpected symbol `<'

Assets/PlayMaker Custom Actions/TextMeshPro/getTextmeshProText.cs(133,8): error CS1012: Too many characters in character literal

I use Unity 5.5.0 and Playmaker 1.8.3

Title: Re: Set color on a specific character of a text
Post by: tcmeric on May 23, 2017, 08:36:07 PM
It looks like textmesh pro (free edition) updated within the last 24 hours. Previous to this, things were working fine. Ill have look to see what changes they made and how I can update the actions.
Title: Re: Set color on a specific character of a text
Post by: tcmeric on May 23, 2017, 09:03:36 PM
Nope, still not getting any errors. I used a fresh scene, with a new copy of my actions and the latest version of textmesh pro free. Are you using the free edition?

Should be version 1.0.55.0b9.
Title: Re: Set color on a specific character of a text
Post by: Rabagast on May 24, 2017, 08:17:53 AM
Nope, still not getting any errors. I used a fresh scene, with a new copy of my actions and the latest version of textmesh pro free. Are you using the free edition?

Should be version 1.0.55.0b9.

I updated TextMesh Pro to the latest version, but I still get the errors.
But I think I know what the problem is. The files looks like html-files, because I right clicked the linked and clicked on save link. It was no other save options there, so I just tried for fun. I thought it worked, since the files have .cs. So how can I download the files?
Title: Re: Set color on a specific character of a text
Post by: Rabagast on May 24, 2017, 08:20:42 AM
I can copy the code to a brand new C#. It works. :)
Title: Re: Set color on a specific character of a text
Post by: Rabagast on May 29, 2017, 05:59:49 PM
I get a lot of errors on Text Mesh Pro when I build the game.

This is just one of many errors.

Assets/PlayMaker Custom Actions/TextMeshPro/Advanced/enableTextmeshProAutoSizeText.cs(40,3): error CS0246: The type or namespace name `TextMeshPro' could not be found. Are you missing an assembly reference?

Title: Re: Set color on a specific character of a text
Post by: Rabagast on May 29, 2017, 08:31:01 PM
I took a screenshot of the console window with all the errors.
I tried the same project with Unity 5.6.1. But I still get the errors.
Except with a brand new project with Text Mesh Pro all all the Actions, then I didn't get any errors. Is it a way to fix this?
Title: Re: Set color on a specific character of a text
Post by: Orjax on May 29, 2017, 09:43:36 PM
Or, couldn't you just make the PL1 and the score, two separate text objects?  Then its easy to set each color.  Just a thought, I'm a newb so maybe I'm missing something.
Title: Re: Set color on a specific character of a text
Post by: Rabagast on June 02, 2017, 05:54:47 PM
Or, couldn't you just make the PL1 and the score, two separate text objects?  Then its easy to set each color.  Just a thought, I'm a newb so maybe I'm missing something.

I use to do that also, but in this case, I have the score in the center, so it always will be in the center when I add score, then the score will overlap the name I use before the score "PL1 000, 000, 000" and "PL2 000, 000, 000". But I got it to work with Textmesh Pro. If I want the name PL1 to be white and the score in red, then it will be something like this:

<color="white"> PL1 <color="red"> 000, 000, 000
Or if you want to use hex colors:
<color=#FFFFFFFF> to get white. :)