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