Search Unity

HOTween issue : How to animate rect()

Discussion in 'Scripting' started by minevr, Jan 3, 2013.

  1. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    How to animate rect(),

    I wan't change UnityGUI rect.;)
     
  2. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi minevr :)

    There is a plugin just for that, between HOTween's default ones. You can simply store a rect property/field to assign at each OnGUI call, and then tween it: values will be changed by HOTween so each time the OnGUI updates the rect will be shown animated. For example, if the rect property is in the same class from where you call the OnGUI method and create the tween, you could do:
    Code (csharp):
    1.  
    2. HOTween.To(this, 2, "myRectProperty", new Rect(0, 0, 200, 100));
    3.  
     
  3. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Thanks,I get it~~ :)

    Anything is string...
     
  4. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I'm not sure what you mean with "anything is string", but just to avoid confusions: the only string you need to insert in HOTween is the name of the property/field to tween (unless you're tweening a string, in which case you'll also need a string for the end value) :)
     
  5. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    BCE0005: Unknown identifier: 'PlugRect'.

    :( How to fixed it?
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    PlugRect is one of the default plugins, so you don't need to write it (and if you do, you'll get that error, since it's not in the Plugins namespace, but in the inaccessible Core one). If you need the TweenParms for the ease, you should do like this:
    Code (csharp):
    1.  
    2. HOTween.To(this, 1, new TweenParms()
    3.     .Prop("Page_01_PageRect", Rect_GUI_On_Left, true)
    4.     .Ease(EaseType.easeInQuad)
    5. );
    6.  
     
  7. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Oh,Thank you very much. :)
     
  8. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Code (csharp):
    1. HOTween.To( this, 2, new TweenParms().Prop( "Int_Page_02", 0, false).Ease( EaseType.EaseOutQuart));
    On Editor, is ok.But build to IOS,animation is false.
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    If you're building for iOS with stripping level set to max, you need HOTweenMicro (same API, so you don't have to change anything in your code: just delete the HOTween files and replace them with HOTweenMicro's).
     
  10. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    I get it~WOW~.Thanks.

    ps:My "Stripping Level" is Disabled
     
  11. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    "Prop( "Int_Page_02", 0, false)"

    if "Int_Page_02" is array,

    Can't support ["Prop( "Int_Page_02[0]", 0, false)"]?

    sorry,so basic...
     
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Ah no, sadly there's no way to animate an element of an Array/List. You can only animate an int/float/etc field/property.
     
  13. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    var Rect_SmallPicBtn_1 : Rect;
    var Rect_SmallPicBtn_2 : Rect;
    var Rect_SmallPicBtn_3 : Rect;
    var Rect_SmallPicBtn_4 : Rect;
    var Rect_SmallPicBtn_5 : Rect;
    var Rect_SmallPicBtn_6 : Rect;
    .....


    Haa~~
     
  14. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Exactly :) And they must be public (which is the default setting for JavaScript in Unity, if I'm correct, so that should work)