unity3d - unity c# Animation property change sprite -


good afternoon .

in animation property ( sprite ) , how change sprite of frame in c #? tried put event calling function takes sprite rendering object , puts in sprite field not change run . runs defined in animation. i'm trying change directly there not know how do.

help please!!

as far i've seen , researched, can't currently.

the best workaround, 1 have done before , highly recommend, create customanimationclip script array of sprites , timer switch each frame next. can change animation's sprites @ time editing array.

here example:

spriterenderer spriterenderer; public sprite[] frames;  [serializefield] int fps; int currentframe = 0;  float frametime; float frametimer = 0;  void awake() {     spriterenderer = getcomponent<spriterenderer>(); }  void start() {     frametime = 1 / (float)fps;     spriterenderer.sprite = frames[0]; }  void update() {     if (frametimer < frametime)     {         frametimer += time.deltatime;     }     else     {         spriterenderer.sprite = frames[currentframe];         currentframe = (currentframe + 1) % (frames.length);         frametimer = 0;     } } 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -