Author Topic: How to make a label text (UIlabel) can read my script string text ? (Solved)  (Read 4087 times)

mattano

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Making Interaction.

How to make a label text (UIlabel) can read my script string text ?

I have a script that gives me the value of my frames per second.
I wish to print my text value into my screen using NGUI.
I wish to add this value into GUI label (label) as text, to make the label print my fps.

How can i achieve this?
Probably is simple. I'm looking in the input script but I'm new.
Is there drag and drop script for it, video tutorial,  or example?

Thanks in advance
« Last Edit: February 19, 2014, 01:19:14 PM by mattano »

davidoakley

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: How do I make a label text (UIlabel) can read my script string text ?
« Reply #1 on: February 19, 2014, 09:32:28 AM »
The short answer is...

Do NGUI -> Create -> Label

In your MonoBehaviour class, add a
  1. public UILabel myLabel;

Back in the editor, select the object that you've got your MonoBehaviour attached to, and drag and drop the Label from the Hierarchy to the My Label field in the Inspector.

Now you can do:
  1. myLabel.text = myFPS.ToString();

Hope that helps!

David

mattano

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: How do I make a label text (UIlabel) can read my script string text ?
« Reply #2 on: February 19, 2014, 10:03:25 AM »

Thank you very much David. It is perfect!
Now i can go on myself
Kind Regards Alan Mattano