Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Bob JJ on August 02, 2014, 10:55:38 AM

Title: best way to reference UIlabels
Post by: Bob JJ 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.
Title: Re: best way to reference UIlabels
Post by: ArenMook 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. }