Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: samix on May 30, 2015, 03:47:34 AM

Title: DOTween.To with classic get and set
Post by: samix on May 30, 2015, 03:47:34 AM
Hi friends,
I'm a bit confuse about the "DOTween.To". I don't understand how to use it with classic get and set:



      float _floatVal = 0f;

      float floatVal {
         get {
               return _floatVal;
            }
            set {
                  _floatVal = value;
            }
      }
   

      public void Start() {
            DOTween.To (floatVal, floatVal, 1f,1f);
      }



it's giving me this error:
The best overloaded method match for `DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter<float>, DG.Tweening.Core.DOSetter<float>, float, float)' has some invalid arguments


Please let me know what you think.
Thanks
Sam
Title: Re: DOTween.To with classic get and set
Post by: David Racine on May 30, 2015, 09:27:54 AM
You need to pass value with lambdas expressions.

Code: [Select]
// Tween a Vector3 called myVector to 3,4,8 in 1 second
DOTween.To(()=> myVector, x=> myVector = x, new Vector3(3,4,8), 1);
// Tween a float called myFloat to 52 in 1 second
DOTween.To(()=> myFloat, x=> myFloat = x, 52, 1);

Hope it helps.
David
Title: Re: DOTween.To with classic get and set
Post by: samix on June 01, 2015, 06:57:21 PM
Thanks David!
Is it the only way? I'm used to the classic get and set. Lambdas expressions are great option and keep the code very condensed; but I just think that lambdas expressions are also hard to read; and in some case force to add a OnUpdate callback when a get/set would have done the job.

Thanks again David : )