NGUI Tween Animation scale and transform conflict

Source: Internet
Author: User

Ngui we want to do scale and transform at the same time, we will find that the animation does not work as we think.

The reason is that tween scale and tween transform are conflicting calls.

In Tween scale

Used to set Localscale

Tween in Transform

Also used to set Localscale.

This creates a conflict ... The simplest way to do this is to merge the two scripts and delete the Localscale in the tween transform, because you still have to use the tween scale to control the scale.

usingUnityengine;usingSystem.Collections; Public classtweenscaletransform:uitweener{ PublicVector3 from=Vector3.one;  PublicVector3 to =Vector3.one;  Public BOOLUpdateTable =false;  PublicTransform fromt;  PublicTransform tot;  Public BOOLparentwhenfinished =false;    Transform Mtrans;    Vector3 MPos;    Quaternion Mrot;    Vector3 Mscale;    Uitable mtable;  PublicTransform Cachedtransform {Get{if(Mtrans = =NULL) Mtrans = transform;returnMtrans;} }     PublicVector3 Value {Get{returnCachedtransform.localscale; }Set{Cachedtransform.localscale =value;} } [System.obsolete ("Use ' value ' instead")]     PublicVector3 Scale {Get{return  This. value; }Set{ This. Value =value;} }    /// <summary>    ///Tween the value. /// </summary>    protected Override voidOnUpdate (floatFactorBOOLisfinished) {Value= from* (1f-factor) + to *factor; if(updateTable) {if(Mtable = =NULL) {mtable= nguitools.findinparents<uitable>(Gameobject); if(Mtable = =NULL) {updateTable =false;return; } } Mtable.repositionnow=true; }        if(Tot! =NULL)        {            if(Mtrans = =NULL) {Mtrans=transform; MPos=mtrans.position; Mrot=mtrans.rotation; Mscale=Mtrans.localscale; }            if(FROMT! =NULL) {mtrans.position= Fromt.position * (1f-factor) + tot.position *factor; Mtrans.rotation=Quaternion.slerp (fromt.rotation, tot.rotation, factor); }            Else{mtrans.position= MPos * (1f-factor) + tot.position *factor; Mtrans.rotation=Quaternion.slerp (Mrot, tot.rotation, factor); }            //Change The parent when finished, if requested            if(parentwhenfinished && isfinished) mtrans.parent =tot; }    }    /// <summary>    ///Start the tweening operation. /// </summary>    Static  PublicTweenscaletransform Begin (Gameobject go,floatDuration, Vector3 scale, Transform from, Transform to) {Tweenscaletransform Comp= uitweener.begin<tweenscaletransform>(go, duration); Comp. from=Comp.value; Comp.to=Scale ; COMP.FROMT= from; Comp.tot=to ; if(Duration <=0f) {comp. Sample (1f,true); Comp.enabled=false; }        returncomp; } [ContextMenu ("Set ' from ' to current value")]     Public Override voidSetstarttocurrentvalue () { from=value;} [ContextMenu ("Set "to" Current value")]     Public Override voidSetendtocurrentvalue () {to =value;} [ContextMenu ("assume value of ' from '")]    voidSetcurrentvaluetostart () {value = from; } [ContextMenu ("assume value of ' to '")]    voidSetcurrentvaluetoend () {value =to ;}}

NGUI Tween Animation scale and transform conflict

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.