Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by danshampf · Nov 10, 2014 at 06:36 PM · animationuisprite4.6

Animated Sprite in UI Canvas?

Hope this isn't too much of a noob question, but I can't seem to find good information on it: I'd like to add an animated sprite (i.e. with proper Animation Controller) to a Unity 4.6 UI Canvas, but don't quite know what's the right way to do it. For static images I know to just add a UI->Image, but there's no UI->Sprite. Is the combination of Sprite Renderer and Canvas Renderer even supported?

I tried adding an animation controller to a UI Image, but that didn't play the animation. Then I tried removing the 'Image' component and adding a Sprite Renderer instead, which sort of works but not really (animation plays, but is displayed in scene view only, and the sprite is tiny). The same happens if I do it the other way around, start with a sprite and then add the Canvas Renderer.

Tips appreciated! :) Thanks

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image theLittleSettler · Nov 10, 2014 at 10:08 PM 0
Share

$$anonymous$$aybe there's a unity script now, but we just had a script that iterated through a bunch of images, assigning them to the Image. Its probable SpriteRenderer is legacy, and doesn't work with the ugui.

avatar image danshampf · Nov 11, 2014 at 12:42 AM 0
Share

Thanks for the answer. I know I could code something up in a script that does it manually, but I was hoping I could use the animation tools that Unity offers, just for convenience. It seems unlikely that the Sprite Renderer is legacy, since it hasn't been that long since all the 2D stuff was introduced, afaik.. But perhaps it was never meant to be used in combination with the UI system (?).

avatar image Onewaysidewalks · Jan 04, 2015 at 05:32 PM 0
Share

Bump? This has been bugging me as well... Find an answer to this?

avatar image tonycoculuzzi · Jan 11, 2015 at 06:09 PM 0
Share

I currently have a UI Image animating with an Animator, but I have another UI Image in the same canvas that just won't animate. It makes no sense.

Edit: Just made the sprites smaller, and now it animates.

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by hersheys72 · Jan 06, 2016 at 05:21 AM

To change from a sprite to an animation you have to follow the steps found at :

http://answers.unity3d.com/questions/931917/animate-image-ui-with-sprite-sheet.html

http://answers.unity3d.com/questions/599122/how-to-make-circle-progress-bar-using-sprite-rende.html#answer-1122639

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by HappySaila · Jan 28, 2016 at 01:27 PM

What i basically did was change the sprites of an image on your GUI. This code just plays like a 10 frame nuke bomb on the players hud public class NukeScript : MonoBehaviour { public Image image;

 public Sprite[] sprites;

 public float animationSpeed;
 
 public IEnumerator nukeMethod()
 {
     //destroy all game objects

     for (int i=0; i < sprites.Length; i++)
     {
         image.sprite = sprites[i];
         yield return new WaitForSeconds(animationSpeed);
     }
 }

}

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HappySaila · Jan 28, 2016 at 05:24 AM 0
Share

oh,,, animationSpeed/sprites.Length, this will end the animation on your desired time.

avatar image
0

Answer by legendbone · Jan 05, 2015 at 10:16 AM

You can set the canvas to screen space-camera ,then set an uicamera and pick the ui layer.but there cause another question :the canvas sort order is no longer working.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by piyusnitnware · Dec 02, 2016 at 08:17 AM

Create an empty UI game object and make child your animated sprites to newly created UI gameObject. Now you can use it anywhere in your UI.

This works for me.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 4.6: How to fit center byte array png in the Image UI? 1 Answer

4.6 play animation on game over 0 Answers

Best way to change sprite in Image (GUI 4.6) ? 1 Answer

Set active button after sprite animation. 0 Answers

Loading built-in resources 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges