Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 OnYtoln147 · Jan 03 at 03:35 PM · renderingcanvasuser interfacesetactive

Insane amount of CPU power used to activate UI inventory window

Hey everyone,

I'm reposting this, because I noticed that help room basically completely inactive.


I've been having random issues lately, that never occured before, with my inventory UI. I have not touched it for legit like a month and yet sometimes opening inventory results in massive fps drop on a frame when the key to open inventory is pressed.


The whole process sometimes takes over 40 ms! Which is just insane. I don't know how this thing triggers, but when I restart unity, the spikes usually vanish for a while, but after some time of testing and working with my code the issues happen again. However even when the issue does not appear in it's 'full power', opening invenotory takes around 7-8 ms (4-5 ms to update canvas and 2-3 ms to activate Inventory and Equipment elements on the canvas)

Profiler

Here on the image you can see the actual results from the profiler. The huge spikes happen when I open the Inventory (which activates game object Inventory and Equipment on my canvas)

Image with the better scenario: https://prnt.sc/25s7d35

Hierarchy

And here is my main canvas in the hierarchy. Basically this one only has hp bar, mana bar, inventory and equipment UI. Inventory has 40 slots.


Since I can't add anymore attachments to this post, I'm sending the rest of the information via links to the images.

https://prnt.sc/25s54pi

This image contains the structure of my inventory slot. Inventory slot parent has inventory slot script, that handles adding items into the inventory slot, updating icon, showing remove button and updating item stack size if needed.


ItemButton contains image and button component and on click script that has IPointerClickHandler to detect clicks in given interval.


RemoveButton has image and button with a function that is called in the inventory slot script on the InventorySlot object.


ItemStackSize has text and an outline.


None of the inventory uses update method or anything similar. Inventory only updates when items are added into it, when they are consumed (potions) or when they are equipped or unequipped.


These fps drops only happen when you open the inventory.


This is how my UI looks: https://prnt.sc/25s6mrn


Anyone know how to fix these issues? They just don't make any sense at all to me. I know that changing one thing at canvas forces the game to recalculate whole canvas again, but this problem only appears when I activate the inventory object. Equipment object in fact has no effect at all on the game. As you can see on the profiler image, in the worst case scenario for some reason it takes whole 12 ms to just activate game object and 28 more to rebuild the canvas. Even in the best case scenario (which is majority of the time, especially after I restart unity) the activation of UI takes 8 ms which is still insanely crazy and I just have no idea why is this happening.

hierarchy-inventory.png (8.1 kB)
canvas-activation-ms.png (169.2 kB)
Comment
Add comment · Show 3
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 wfreeman480 · Jan 03 at 05:52 PM 0
Share

Do you have a lot of items under the update() function? I know that can be CPU intensive but this UI doesn’t look like it’d be so intensive

avatar image OnYtoln147 wfreeman480 · Jan 03 at 06:22 PM 0
Share

Hello, inventory does not use anything related to update, and in fact, once it's open, even if you update item slots 100 times per frame, the game doesn't even feel it. This issue only happens when you SetActive the Inventory object. Equipment object also has no impact at all.

avatar image wfreeman480 OnYtoln147 · Jan 03 at 07:23 PM 0
Share

That’s odd. I googled some things that might cause some high cpu usage. Try adding this to your start method and see if this changes anything Application.targetFrameRate = 60;

Also I’d try to attach your code to this post

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by wfreeman480 · Jan 03 at 07:32 PM

After some research I saw that a lot of people switch their UI components with TextMeshPro and that helped. Also have you tried running the game in it’s executable.

Comment
Add comment · Show 10 · 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 OnYtoln147 · Jan 03 at 10:16 PM 0
Share

hello I had text mesh pro in there, switched to normal text to see if there is any difference and there is actually none

and yes i tried running built game and even if i spamm the inventory you can't feel it because the fps is still over 120, however the game is in a pretty early stage, so it might be worse later

avatar image OnYtoln147 · Jan 03 at 10:20 PM 0
Share

this must surely be a bug, I don't see how this can make sense in any way

avatar image wfreeman480 OnYtoln147 · Jan 04 at 12:14 AM 0
Share

I agree. When I was googling people were talking about this actually being a possible bug related to some text elements. One forum I read said that the problem magically disappeared overtime. I wish I could help you more.

avatar image OnYtoln147 wfreeman480 · Jan 04 at 12:21 AM 0
Share

ill pray for it to disappear over time lol, honestly have no clue how 40 slot inventory can take 3 ms to activate and 5 ms to rebuild

however it's insanely frustrating for me not to be able to figure this out and fix it, i shouldn't even care probably because u are not going to open inventory every frame...

Show more comments
avatar image
0

Answer by OnYtoln147 · Jan 04 at 01:12 AM

A little update, I moved from Unity 2020.3.17f1 to 2020.3.18f1 and the performance issue is basically halved, now it takes 4-5ms for inventory to open (2ms for gameobject.SetActive and 2 ms to build canvas).

At this point it feels like a joke. Must be some terrible bug because I have no clue how can this be happening.

Issue still unresolved!

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

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

Related Questions

Strange error with UI Screen overlay - no bugs or warning, game can't be played. - GameOverText.SetActive (false); 0 Answers

How to render canvas with screen space - camera on top of canvas with screen space - overlay? 2 Answers

Need UI Canvas to appear AFTER audio finishes on trigger 2 Answers

UI element highlight OnPointerEnter effected by Hierarchy order of children? 1 Answer

3D Objects on a UI canvas with LWRP? 2 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