Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: vallcrist on May 05, 2014, 03:04:55 PM

Title: Data binding with getters
Post by: vallcrist on May 05, 2014, 03:04:55 PM
Why isn't it possible to Data bind to a Getter?

It would be very useful if we could, since in some cases we need to show data of one of our Singletons, and it would be easier to just write a getter instead of writing the whole "void Update() { value = Singleton.instance.value }".

Any thoughts on it?
Title: Re: Data binding with getters
Post by: ArenMook on May 05, 2014, 11:48:21 PM
Sure you can. I just double-checked to make sure.
  1. using UnityEngine;
  2.  
  3. public class Test : MonoBehaviour
  4. {
  5.         PropertyReference prop;
  6.  
  7.         public int testMe { get { return 123; } }
  8.         public int testMe2 { get { return 123; } set { } }
  9. }
Both testMe and testMe2 show up in inspector when I drag this object into the "Prop" field. What are you doing, exactly?
Title: Re: Data binding with getters
Post by: vallcrist on May 07, 2014, 07:02:17 AM
Got it, i needed to add a empty seter for it to show up. =)