Making UI sprite animation | Unity Tutorial

preview_player
Показать описание
This video will show you how to animated UI just like 2d Animation.
2: The code will loop the sprite animation you referentce.
3: Create a UI image to run animation and 2 button to play and stop animation on the image.
4: Pull the script to UI image, then reference the image and the sprite to "inspector script"
5: Now you can click play and you can play or stop the animation. You also can control speech of animation.
You can see more detail here:
Project on Github:

Hope this can help you.
Рекомендации по теме
Комментарии
Автор

Fabulous. Worked for me. I wanted an animation to run over a button at the UI level. I narrowed the options down to image but couldn't work it out. Your vid nailed it. I used this from stacked to run without the buttons:

IEnumerator doAnimation()
{
for (int i = 0; i < spritearray.Length; i++)
{
yield return new WaitForSeconds(0.03F);
myImage.sprite = spritearray[i];
}
}

Your vid was way too fast though. Had to run at 0.25 speed to get it.

Many thanks again. 👍

robbayley
Автор

hi, please reply, is it frame rame indpendent. or should i use time.deltatime somewhere.

arunachalpradesh
Автор

Thanks for your script! How can I quickly disable loop animation for sprites through your script?

VsevolodPankratov
Автор

You are a legend. Thank you thank you thank you thank you thank you thank you my friend.

santunu
Автор

I can't learn anything at this speed runner tuto. -1

dragonbleu
Автор

What are the benefits of using script in place of directly animator controller?

Mendogology
Автор

public Image image;
public List<Sprite> sprites;
public float animSpeed = 1;
private int index;
private bool isDone;

// Start is called before the first frame update
void Start()
{
StartCoroutine(StartAnim());
}

IEnumerator StartAnim()
{
while(true)
{
yield return new WaitForSeconds(animSpeed);
index++;
if(index >= sprites.Count)
index = 0;
else
image.sprite = sprites[index];
}
}

Cabessudo
Автор

does anyone know how to modify the code to let it play only once?

jesterspades