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 GambinoInd · Feb 26, 2014 at 05:36 AM · guiperformanceatlas

GUI Performance & Texture Atlasing

I've been developing my RPG, and have had awful performance with the GUI System. It really lowers my FPS, and I'm trying to find a way to improve the performance but I have a few questions.

GUI Off:

GUI Off

GUI On:

GUI On

I was looking into reducing draw calls by using a texture atlas. I have the same texture repeated 10 times in a row right next to eachother (The buttons on the bottom right of my GUI) and it still uses 10 draw calls, rather than 1. Does texture atlasing actually reduce the draw calls and improve the performance of the GUI?

I am not drawing very much on the screen, 10 buttons with 10 images on the buttons, 3 images for the minimap, and about 5 images for the chatbox and a few labels. I think that's very little to be drawn on the screen, and it's really destroying my FPS. What could be the cause?

Here is a little bit of code drawing the buttons on the bottom right.

         //Draws tabs
         private void DrawTabs ()
         {
                 GUI.DrawTexture (new Rect (Screen.width - 1, Screen.height - Config.TAB_BUTTON_HEIGHT, 1, Config.TAB_BUTTON_HEIGHT), tabBackground [3]);
                 int activeTabIndex = 0;
                 for (int i = 0; i < Config.MAX_TABS; i++) {    
                         //Checks to see if tab is enabled
                         if (!tabSystem.isTabEnabled (i))
                                 continue;
             
                         int x = Screen.width - ((activeTabIndex + 1) * Config.TAB_BUTTON_WIDTH) - 1;
                         int y = Screen.height - Config.TAB_BUTTON_HEIGHT;
                         Rect rect = new Rect (x, y, Config.TAB_BUTTON_WIDTH, Config.TAB_BUTTON_HEIGHT);
                         GUIButtonSystem.TextureButtonHover2 (rect, tabBackground [0], tabBackground [1], tabSystem.getCurrentTab () != i ? "Open Tab" : "Close Tab", "", ClickTab, i);
                         if (tabSystem.getCurrentTab () == i) {
                                 GUI.DrawTexture (rect, tabBackground [2]);
                         }
                         if (tabIcons [(i * 2)] != null && tabIcons [(i * 2) + 1] != null)
                         if (tabSystem.getCurrentTab () != i)
                                 GUIButtonSystem.TextureHover (rect, tabIcons [(i * 2)], tabIcons [(i * 2) + 1]);
                         else
                                 GUI.DrawTexture (new Rect (rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4), tabIcons [(i * 2)]);
                         activeTabIndex++;
                 }
         }

     public static void TextureButtonHover2 (Rect rect, Texture buttonTexture, Texture buttonHoverTexture, string action, string name, RightClickHandler.menuActionDelegate del, int id)
     {
         bool inButton = rect.Contains (MousePositionHandler.getMousePositionVerticalSwitch ());
         GUI.DrawTexture (rect, inButton ? buttonHoverTexture : buttonTexture);
         if(inButton) {
             RightClickHandler.addMenuItem(action, name, del, id, 0);
         }
     }

As you can see, I'm not doing anything too crazy with the code. Why is my performance so bad? All help is really appreciated.

Comment
Add comment · Show 2
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 robertbu · Feb 26, 2014 at 07:17 AM 0
Share

The way I understand it, each GUI call generates a drawcall. Third-party solutions like NGUI and EZGUI use world object and a texture atlas to allow the drawcalls to batch. People in the know say that Unity's upco$$anonymous$$g new UI tools will be based on NGUI. In the meantime you are stuck either purchasing a third-party solution, or rolling your own solution using world objects if you want to reduce drawcalls in your UI.

Note if your row of icons on the lower right are what is causing your drawcalls, you could draw them as one texture and use your own hit detection code to figure out what was clicked. If there are state involved, you might need to have a number of combinations. Just a thought.

avatar image GambinoInd · Feb 26, 2014 at 07:22 AM 0
Share

Unity really needs to release the new GUI system. It's really slow, and it's simply drawing images on the screen.

0 Replies

· Add your reply
  • Sort: 

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

20 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

Related Questions

Best way to create mini hp-bars for enemies. 1 Answer

Can EditorWindows dynamically display interfaces of other Editor Windows ? 1 Answer

WorldToScreenPoint in Update/OnGUI: Bad Performance 1 Answer

s-pen GUIUtility.BeginGUI performance problems 0 Answers

single texture atlas or multiple textures? 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