Author Topic: Trying to assign label to a variable with java script.  (Read 3944 times)

Rick74

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Trying to assign label to a variable with java script.
« on: October 15, 2013, 10:24:40 AM »
Hey guys, I'm having trouble trying to assign a label to a variable with Java.  Would any of you have any experience at this?

  1. var getFont:                            UILabel;
  2.  
  3. function Start ()
  4. {
  5.       getFont                   = GameObject.Find("btn_Cow/cost");
  6. }

Of course, cost resides inside "btn_Cow" and is a simple widget/label.  So far I've tried; Material.Find, GameObject.Find, and UILabel.Find.  All give me the error;

Assets/Scripts/CowButtonCoolDown.js(28,50): BCE0022: Cannot convert 'UnityEngine.GameObject' to 'UILabel'.

I can manually assign the UILabel just fine(drag and drop through the inspector), but I would prefer the code auto assign it, so I don't have too.

Rick74

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: Trying to assign label to a variable with java script.
« Reply #1 on: October 15, 2013, 10:29:30 AM »
I'm sorry guys, I guess typing this out helped me get to the answer.  Which is the variable is a game object and by assigning it to the UILabel, it just knows what it is.

My bad.

 ;)