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.
usingUnityEngine;
publicclass Test : MonoBehaviour
{
PropertyReference prop;
publicint testMe {get{return123;}}
publicint testMe2 {get{return123;}set{}}
}
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. =)