Search Unity

Changing an UI Image's sprite via Animation keyframes

Discussion in 'UGUI & TextMesh Pro' started by Vordyn, Oct 8, 2018.

  1. Vordyn

    Vordyn

    Joined:
    Sep 15, 2017
    Posts:
    11
    Hello,

    On both Unity 2018.2.10 and 2018.2.11, I've been experiencing something that seems like a bug, and I hoped someone here could help.

    I've got an UI Image (child a of canvas), on which I want to use a spritemap (it will constantly have to switch between the sprites 0/1/2/3, looping). Nothing complicated in theory.

    When I add an Animation component to my Image object, I add the Image.Sprite property to the clip, and am able to drag&drop all sprites I want on specific keyframes. But nothing changes when I play the animation. The Image keep showing only its default sprite.

    I've tried multiple things (changing the animated steps, using only non-spritemap sprites...) it never seems to do anything. When I try (in the same animation) to change anything else (a position by example), it works perfectly, so I know it is running. But the sprite isn't changing.

    I somehow found a workaround (by using a RawImage and animating its UVRect.x/y), but I wish I could simply use sprites as I should (drag&dropping sprites on the Animation tab would not exist otherwise, I think)

    Am I missing something obvious ? Can UI.Image.Sprite not be animated at all ?
     
    jf065d likes this.