playMaker

Author Topic: Set color on a specific character of a text  (Read 3711 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Set color on a specific character of a text
« on: May 23, 2017, 01: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?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

edufurla

  • Playmaker Newbie
  • *
  • Posts: 42
    • View Profile
Re: Set color on a specific character of a text
« Reply #1 on: May 23, 2017, 01: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

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 745
    • View Profile
Re: Set color on a specific character of a text
« Reply #2 on: May 23, 2017, 04:59:46 AM »
Also textmesh pro now has playmaker actions.

https://github.com/dumbgamedev/TextMeshPro_Playmaker

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Set color on a specific character of a text
« Reply #3 on: May 23, 2017, 01: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?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Set color on a specific character of a text
« Reply #4 on: May 23, 2017, 02: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

Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 745
    • View Profile
Re: Set color on a specific character of a text
« Reply #5 on: May 23, 2017, 05: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.

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 745
    • View Profile
Re: Set color on a specific character of a text
« Reply #6 on: May 23, 2017, 06: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.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Set color on a specific character of a text
« Reply #7 on: May 24, 2017, 05: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?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Set color on a specific character of a text
« Reply #8 on: May 24, 2017, 05:20:42 AM »
I can copy the code to a brand new C#. It works. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Set color on a specific character of a text
« Reply #9 on: May 29, 2017, 02: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?

Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Set color on a specific character of a text
« Reply #10 on: May 29, 2017, 05: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?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Orjax

  • Playmaker Newbie
  • *
  • Posts: 21
  • Father/son team, self taught, love learning
    • View Profile
Re: Set color on a specific character of a text
« Reply #11 on: May 29, 2017, 06: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.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Set color on a specific character of a text
« Reply #12 on: June 02, 2017, 02: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. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no