playMaker

Author Topic: Resizing GUIText Size [SOLVED]  (Read 11872 times)

yurgalavage

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Resizing GUIText Size [SOLVED]
« on: February 13, 2012, 08:14:20 AM »
Using the GUI actions from playmaker to display text, can you:
 
1) pick a font?
 2) change font size?
 3) change text of a label or box 'on the fly' (i.e. update score)
 4) change font color?
 
Also, if you have a game and your max resolution is going to be 1900X1200 or something BUT the user can play at lower resolutions, is there a way to 'resize' text logically to fit the new screen resolution?
 
You have to admit these are pretty common and important questions for any GUI or score display.

NOTE THE IMAGE BELOW:



I have created a GUIText holding the score value, let's say.

Here is the Component Inspector values for the GUIText Object:



also note the inspector for the FONT used:



So the questions above still stand.  I am looking at the playmaker actions and I don't see a clear way to:

How do you change the font using playmaker action (if desired)?
How do you change color of the GUIText using playmaker action (if desired)?
How do you change the font size of the GUIText using playmaker actions (if desired)?

Changing the font size (or 'resizing dynamically' the GUIText) is important if your GUI is showing an item (let's say SCORE) and the maximum screen size might be variable (i.e. user selects different screen resolution, so you have to 'resize' your GUIText size and placement based on the new screen size, etc.)

Also, note that if you change the FONT color using the FONT inspector, then ALL GUIText Objects that use that font are affected.  Isn't there a simple way to change color of each GUIText Object without affecting all the rest?  This is a stupid UNITY3d limitation, if so.  I am assuming that if playmaker doesn't allow this with an action, then you have to make some sort of script and add it to the GUIText to give you a color var.  

I am posting here so I don't keep hijacking the 3dUnity forums thread for playmaker.  :D
 
best,
 Mike
« Last Edit: February 13, 2012, 12:53:47 PM by yurgalavage »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3631
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Resizing GUIText Size
« Reply #1 on: February 13, 2012, 10:05:29 AM »
Take a look at the Set Property actions - it gives you generic access to most properties in behaviours etc.

Drag the component you want to access onto the Target Object field, then find the property you want to change in the Property dropdown list.

I've attached a screenshot example.

I'm not sure what the usual Unity way to change individual  GUIText colors is... it might be worth searching on the unity forums or UnityAnswers, then see if there's an equivalent in Playmaker...

yurgalavage

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: Resizing GUIText Size
« Reply #2 on: February 13, 2012, 12:53:25 PM »
Thanks Alex.  That just opened up a WHOLE NEW WORLD for me.  I didn't realize I could do this (i.e. drag components into the Property action and access them).  I am able to resize and chose my Font accordingly now.  Thanks!


As far as I know, you have to create a script to expose a separate color for your GUIText, since it doesn't exist in the properties Inspector.  Seems like a glaring omission by Unity3d to me, since choosing color of your text would be very common (as long as the text is unicolor and not a gradient, and even then the color still affects your text color).

Here's one if people need it (attribution left in place):


#pragma strict

//this script changes the guiText color of the object and should be attached to an guiText object
//from http://www.plinan.com
var TextColor : Color = Color.white; // define the default color for this guiText object

function Start () {

guiText.material.color = TextColor;

}

function Update () {

}


I am sure I will have more questions as I go along.

thanks again,
Mike