Search Unity

iTween.ValueTo

Discussion in 'Scripting' started by dashmasterful, Oct 3, 2010.

  1. dashmasterful

    dashmasterful

    Joined:
    Feb 3, 2010
    Posts:
    166
    I'm trying to ease a motionblur inside a script attached to the camera

    Hashtable ht = new Hashtable();
    ht.Add("from",0);
    ht.Add("to",.92f);
    ht.Add("time",.5f);
    ht.Add("onupdate","changeMotionBlur");
    iTween.ValueTo(this,ht);

    of course "this" is the script itself and not a gameobject, how can I make this work, also what am I supposed to put in the changeMotionBlur method, I can't any examples on their website or anywhere else
     
    UnivrseCore likes this.
  2. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    You will need to provide a GameObject to ValueTo() in order for this to work and your "onupdate" callback just needs to accept the same type of value you are trying to tween. If you can't use an existing GO maybe create a dummy one on the fly?

    void Start(){
    //establish parameter hash:
    Hashtable ht = iTween.Hash("from",0,"to",.92f,"time",.5f,"onupdate","changeMotionBlur");

    //make iTween call:
    iTween.ValueTo(gameObject,ht);
    }

    //since our ValueTo() iscalculating floats the "onupdate" callback will expect a float as well:
    void changeMotionBlur(float newValue){
    //apply the value of newValue:
    print(newValue);
    }

    Also there are a few examples on the support page that show usage of ValueTo: http://itween.pixelplacement.com/examples.php
     
    Charlivi, tomasdgarcia and Sungold like this.
  3. dashmasterful

    dashmasterful

    Joined:
    Feb 3, 2010
    Posts:
    166
    thank you, this is just what I was looking for
     
  4. pixelplacement1

    pixelplacement1

    Joined:
    Aug 19, 2009
    Posts:
    674
    Glad I could help!
     
  5. DarkSlash

    DarkSlash

    Joined:
    Sep 30, 2011
    Posts:
    128
    I bought the native extension, and .ValueTo seems not to be on the list of attached functions, is that correct?
     
  6. kriston9876

    kriston9876

    Joined:
    Jan 7, 2019
    Posts:
    2
    Your content helped me a lot to take my doubts, thank you very much.
     
    Last edited: Jan 8, 2019
  7. kriston9876

    kriston9876

    Joined:
    Jan 7, 2019
    Posts:
    2
    great idea