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 /
  • Help Room /
avatar image
0
Question by OnYtoln147 · Jan 03 at 05:30 AM · canvasuser interfaceinventory system

Insane amount of CPU power used to activate UI inventory and equipment windows

Hey everyone,

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, 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.


Thanks to anyone for any help provided.

canvas-activation-ms.png (169.2 kB)
hierarchy-inventory.png (8.1 kB)
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

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

183 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 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

World space to world canvas space? 0 Answers

Question regarding sending clicks to another UI canvas. 1 Answer

Trying to put a canvas in Google Cardboard 0 Answers

Fit elements in canvas with 1:2 ratio and make them keep it 0 Answers

UI Canvas draw order 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