Author Topic: best way to reference UIlabels  (Read 2291 times)

Bob JJ

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
best way to reference UIlabels
« on: August 02, 2014, 10:55:38 AM »
Hi we are currently making our first game and slowly getting the hang of everything, Just wondering what the best way to reference all the labels in our game would be.

We have quite a few labels that need to be updated dynamically like gold, stone, cash, dynamic text etc.

I was thinking the best way would be to make a gameobject called uilabelstore and store them all there as public static variables for easy reference in other scripts but not sure how to go about it. Any help with some code to go along with it would be great help.

Thankyou in advance.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: best way to reference UIlabels
« Reply #1 on: August 03, 2014, 09:31:22 AM »
  1. using UnityEngine;
  2.  
  3. public class UILabelStore : MonoBehaviour
  4. {
  5.     public UILabel gold;
  6.     public UILabel stone;
  7.     public UILabel cash;
  8.     public UILabel dynamicText;
  9. }