- Home /
Animating a Sprite Image in UI from Code
Hey guys,
I'm currently making a project where a dialogue canvas contains an empty image. When dialogue is called, an image associated with the npc is passed in and appears on the screen. The only problem is i want these images to loop a talking animation. How would i pass in the information need to call an animation for each npc? Should i create these animations ahead of time and just call the animation on the canvas? If so how do i go about doing this? Any help and comments are greatly appreciated. Thanks!
Answer by GamitusLabs · Dec 09, 2018 at 05:08 PM
Short answer, yes, create the animations ahead of time.
You make the animations, put them in a controller, then when the dialog is opened pass the Sprite Renderer component to your animator. And, if you're cleaver with your dialog system, you could just pass the component to each successive speaker in the conversation.
Thank you for clarifying! will definitely try to implement this into my dialogue system :)
Your answer
Follow this Question
Related Questions
Change UI GUI Image Sprite at runtime .. Unity 5 .. js 1 Answer
How I can attach an image or animation on the uiImage fill amount? 0 Answers
Child Image of Animated Panel Shaking 1 Answer
Sprite.Create() only works the first time and eventually causes "Invalid AABB" errors. 2 Answers
UI Elements Move Animation Using iTween 2 Answers