playMaker

Author Topic: A simple text string with a font and color of my choise  (Read 4948 times)

FritsLyn

  • Full Member
  • ***
  • Posts: 191
A simple text string with a font and color of my choise
« on: July 06, 2013, 09:43:34 AM »
I am asking this question partly because I need the answer but also because I imagine there will be many after me who would like this answer as well.

I Just want to write "Score: XXX" on my game screen with a specified font and color.

The easy parts:
* Working with strings
* Writing text with the initial settings

The confusing parts:
* Everything is called GUI, and there's some "battle" between Unity GUI systems and PlayMaker GUI systems, but then again, Playmaker is drawing from some of Unity's core.. !!

QUESTION:

With the intent of not doing anything complicated, just a simple "SCORE: XXX" text in the top right corner, but being able to chose font, size and color - then what would be the smartest / most basic way to do this?

Thanks :)
« Last Edit: July 09, 2013, 01:09:28 AM by FritsLyn »

fromfame

  • Junior Playmaker
  • **
  • Posts: 78
  • Sloppy PM Veteran
Re: A simple text string with a font and color of my choise
« Reply #1 on: July 08, 2013, 08:37:00 AM »
We desperately need someone to answer this, i have the same problem lol

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A simple text string with a font and color of my choise
« Reply #2 on: July 09, 2013, 01:12:53 AM »
I think learning how to do this basic task the best way would help a lot of people learn the rest more easily.

As of now, it is hard to see through "how to get started" with a simple "Hello World", and so I am afraid to do something overly complex for a simple thing, take much too long time to learn the rest etc.

Anyone out there? Thank you :)

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: A simple text string with a font and color of my choise
« Reply #3 on: July 09, 2013, 01:38:04 AM »
Easy mode!

Color - Black
<color=#000000>"string"</color>
Size - 40
<size=40>"string"</size>

Both color and size
<color=#000000><size=40>"string"</size></color>

Use build string to add the color and size as needed
Check this out for more magic
http://docs.unity3d.com/Documentation/Manual/StyledText.html

Changing the font would be done via set property - let me know if you need more explanation for that.
« Last Edit: July 09, 2013, 01:53:02 AM by LampRabbit »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: A simple text string with a font and color of my choise
« Reply #4 on: July 09, 2013, 02:45:42 AM »
Hi,

Also, be aware this is only available in Unity 4, unity 3 doesn't have rich text capabilities.

When I have to do these kind of work, I tend to rely on having two different label, and I build a guiskin with custom styles to fit my need, and then stack them into a horyzontal area.

 does that make sense? it's far from being ideal I know.. and if you have unity 4, go with LampRabbit explanations, or else use nGUI or other 2d frameowkr, most of them have rich text capabilities.

bye,

 Jean

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A simple text string with a font and color of my choise
« Reply #5 on: July 17, 2013, 04:42:41 PM »
Hmm Thanks a lot LampRabbit and Jean.

LampRabbit: I do not think I can chose a font this way - that's basically my issue :)

Jean: I am back at being stuck with overall confusion here - I need that "AHA!" moment, I cannot see though where Playmaker's things start / end and where native Unity plays a role, in stuff like

http://docs.unity3d.com/Documentation/Components/class-GUISkin.html
https://hutonggames.fogbugz.com/default.asp?W220
http://hutonggames.com/playmakerforum/index.php?topic=1090.0

What I am asking is "just" the overview of what is what, in overall simplified terms:

Unity has a system where you can make GUI styles
Is that "replaced" by PlayMaker?

Is it possible to chose font and color by ONLY using PlayMaker tools, or are they merely accessing something that I have to set up in native Unity?

Do I need to add a component: "GUIText"? (If I do, it does not appear to affect anything that comes from PlayMaker, what, what, what :D

Thanks :)

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3998
  • Official Playmaker Support
    • LinkedIn
Re: A simple text string with a font and color of my choise
« Reply #6 on: July 17, 2013, 04:58:39 PM »
Playmaker doesn't replace GUISkins and GUIStyles. If you use Unity's GUI you will still need to make your own GUI Skins and custom styles in the Unity Editor. It's a bit of a learning curve, but it's fairly well documented in the Unity manual.

You then call these in Playmaker using the Set GUI Skin action and the Style parameter in all GUI actions.

Does that make sense?

Bear in mind Unity has 2 separate GUI systems. The newer system is accessed using the GUI and GUI Layout actions. The older system is accessed using GUI Element actions. These control GUI Text and GUI Texture components in the scene. There are pros and cons to each system, but I think you can find lots of info about that on the Unity forums.