Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by penneyworth1 · Feb 22, 2016 at 05:14 AM · sprites2d sprites

Using an Animator vs. simply manually setting uv's

I am trying to understand if there are any performance advantages to using an Animator and an Animation Clip as opposed to manually switching the mesh.uv array during update() to create an animated sprite on a quad.

Currently I am using the manual method, and it seems to work fine, so I have not looked into the Animation apparatus. I'd rather not create an animator, but before I continue down this path, I wanted to make sure I'm not missing out on a performance advantage that I'm not aware of.

The situation is that I have up to 200 bullets (animated sprite quads) flying around in the scene. They all use different sections of the same large texture atlas. They are each instances of a single prefab which is just a quad with script attached that has a property that holds all the predefined arrays of Vector2 that are the different sets of uv's. During update(), the script sets mesh.uv to the next Vector2 array, and the quad animates perfectly.

I just wanted to get some feedback about this approach before going further having forgone the use of an Animator. Thanks!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by _creatio_ · Feb 23, 2016 at 06:11 PM

@penneyworth1 Your question is a bit context dependent. Of course the Animator has some performance overhead (it probably uses Reflection which creates the most of this overhead), which is not noticeable in simple cases. But if you have hundreds of objects on a complex scene on a mobile devices, things may appear to be different.

You can make a simplified performance test to see if it fits your requirements, prior to making a complex manager class.

One more consideration. Having a black box (the Animator solution), gives you less ways to optimize the behavior of your system. For example, you may decide to skip your calculations on some frames or camera views, etc., or probably make them more complex if your bullets comes very close to the camera.

So if you were just planning the system, checking the Animator solution could be a faster way to accomplish the task. But if you have already made a working solution, just stay cool :)

IMHO, if you have already made a system that does what you need, with appropriate performance - just go on with your other tasks, don't waste your time for unneeded perfection. But if it is just a sort of fun / educational project - checking the alternative solution might be a good point.

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 penneyworth1 · Feb 23, 2016 at 09:26 PM 0
Share

I appreciate the response! Yes, I do have a working solution, but I ask this because I don't know what I don't know. For instance, a while ago I didn't know that changing the material's color at runtime would instance another material and add another draw call, which is a huge performance disaster if you want 100 simple bullets to flash between colors and you choose that approach. I was really trying to find out if there was some similar gotcha when rapidly switching the uv array on a mesh. $$anonymous$$aybe it rebuilds the mesh or something I couldn't have imagined. I can't find any examples of anyone creating sprites by simply cycling arrays of uv's on a mesh, which seems like the simplest solution by far to me, and that worries me a lot. If it isn't a standard practice, there must be some drawback that I don't yet understand. Hope that makes sense.

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

38 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I change the Unity 5 UI hitbox/collider to fit my complex image? 1 Answer

Sprite colors not displaying properly after I click play 2 Answers

How to skew/shear a 2D sprite without perspective? 1 Answer

why are my sprites pixeleted in the game view? 1 Answer

Why are my sprites wierd in Unity? 0 Answers


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