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
0
Question by Overcast · Jun 12, 2015 at 03:44 AM · uiperformanceoptimizationrtsworldtoscreenpoint

Whats an efficient method for drawing hundreds of Health Bars etc. over units for an RTS?

That's the whole question really, I have been using:

  rectTransform.position = Camera.main.WorldToScreenPoint(unit.transform.position);

In the UI elements update event, but it slows down a lot with just that line, once you have 20-30 units. I've tried putting them all on one canvas, and giving each a seperate canvas, but it appears to be the WorldToScreenPoint function causing the slowdown.

There's no real way to call this less than in Update either, at in addition to the unit moving (which you could dead reckon a bit) the screen position and zoom level may change.

Any ideas? This must be have been solved before?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Overcast · Jun 12, 2015 at 01:24 PM

Well I can mark this as solved. It turns out calling Camera.main essentially searched for the camera tagged appropriately every time and is INCREDIBLY slow.

Caching the main camera in a public field of a manager class fixed the problem completely.

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 Eno-Khaon · Jun 12, 2015 at 04:01 AM

I can't say I know for sure what the most efficient approaches are, but I can tell you one thing: The GUI is spectacularly inefficient.

My first thought would be to use 3D objects (planes) with a billboard shader for a baseline. With this, you can have a baseline to work from. From there, some tweaks to initial sizing and general re-scaling of parts should make for reasonably usable health bars.

Comment
Add comment · Show 2 · 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 Overcast · Jun 12, 2015 at 10:16 AM 0
Share

hmmm that's a shame, as I was really hoping to use the new UI elements in game to shortcut things.

Thanks for the advice, anywhere I could go to clarify with Unity that their UI is indeed a bad choice for this sort of thing?

avatar image Eno-Khaon · Jun 12, 2015 at 07:06 PM 0
Share

Generally, it's rather easy to try for yourself.

For either GUI system, display a large quantity of text objects (for the old GUI especially, it only takes 20 to 30 labels to drop from ~250 to ~45 fps, for instance). The increase in draw calls can grow rather quickly, and the more complex the scene (i.e. tons of units needing health displays each), the greater the cost of using the UI.

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

22 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

Related Questions

UI-based game memory and performance issue. 1 Answer

Heavy use of layout groups and content fitters performance 1 Answer

Whats the most efficient method for placing UI elements at world positions? (Above units etc.) 2 Answers

UI Text Optimization? Updating Geometry seems to be slow 0 Answers

Sprite Alpha Performance 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