Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 LilGames · Apr 17, 2019 at 07:30 PM · uicanvasbuttons

Do Buttons dirty the canvas?

Original Question: I'd like to know if a button that uses Sprite Swap, will mark the canvas as dirty when the user hovers the mouse over the button?

*Edit for clarity: When certain parameters change in a canvas, it causes Unity to "rebuild" the mesh via Canvas.buildBatch. This is cpu intensive and can cause spikes/hiccups.

This article mentions only Transform changes as a cause of a rebuild: https://support.unity3d.com/hc/en-us/articles/115000355466-Split-canvas-for-dynamic-objects

The article goes so far as saying that changing text does NOT involve a batch build. My question seeks certainty regarding other types of changes such as a button sprite-swap on hover or the tint effect on hover. (Assume there are NO animations)

Comment
Add comment · Show 5
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 KevRev · Apr 17, 2019 at 08:00 PM 0
Share

What do you mean by dirty?

avatar image LilGames KevRev · Apr 17, 2019 at 08:08 PM 0
Share

It's a common graphics / game / development term for when something changes in your rendering hierarchy, requiring either a re-draw or complete re-calculation of the "stuff" that your visuals are made of. (Though technically the term also applies to non-visual things).

https://gamedev.stackexchange.com/questions/160433/what-is-the-meaning-of-component-is-dirty

avatar image embrain LilGames · Apr 21, 2019 at 09:02 PM 0
Share

Of course also unity has to repaint everything that has changed so whats the point of your question?

Show more comments
avatar image KevRev · Apr 17, 2019 at 08:23 PM 0
Share

I'm new to game development, so blissfully unaware of that one sorry :(

You'll need much smarter Devs to answer that one.

Not sure it'll help, but there is a LateUpdate() function you can use to ensure what you are doing is at the end of the frame, if ti$$anonymous$$g of a particular piece of code per frame is important.

3 Replies

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

Answer by LilGames · Mar 08 at 06:06 PM

I keep asking myself the same initial question and when I Google, I find my own question as a top result, so here's what resources I've found to help me through the whole Static vs Dynamic Canvas decisions:

.

A simple tutorial about correctly setting up the UI hierarchy of mixed Static and Dynamic parts of your UI: https://learn.unity.com/tutorial/nested-canvas-optimization-2019-3#

.

A deeper tutorial explaining a 2-canvas setup and using the profiler to see the impact: https://learn.unity.com/tutorial/working-with-static-and-dynamic-canvases#5ffbd711edbc2a002099bd00

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
1

Answer by xxmariofer · Apr 22, 2019 at 11:15 AM

anything that changes the canvas will force a canvas repaint, not only images, scroll bars buttons animations, anything. thats why you should separate canvas depending on when their objects get dirty, if you have a button that is animated, it should go in a separate canvas from the static buttons.

Comment
Add comment · Show 4 · 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 LilGames · Apr 22, 2019 at 08:50 PM 0
Share

I guess this is where I am looking for more specifics. I assume that animation, scaling, rotation cause a canvas rebuild, but would a simple alpha or tint change? What about sprite-swap method if the sprites are all from the same atlas?

Thank you for your time.

avatar image xxmariofer LilGames · Apr 23, 2019 at 07:53 AM 0
Share

it changes always, even if is such a tiny thing as a tint change, unity doesnt "check" what has changed in the canvas, just as an example, if you have an animation of a button that doesnt do anything the first 5 seconds and the last 5 seconds it applies a tint chaange, the canvas will be redrawn all 10 seconds (all the time, since it doesnt know if something has changed so you would repaint the exact same canvas during 5 seconds) here are some performance tips for canvas uses Link

avatar image LilGames xxmariofer · Apr 23, 2019 at 02:06 PM 0
Share

Redraw/repaint is fast compared to rebuilding the mesh: https://support.unity3d.com/hc/en-us/articles/115000355466-Split-canvas-for-dynamic-objects

Show more comments
avatar image
1

Answer by Bip901 · Mar 28, 2020 at 07:57 PM

According to Unity 2017 Game Optimization by Chris Dickinson, the only action which doesn't dirty the canvas is changing the Color property of a UI element.

Hence I assume a color tint transition won't rebuild the canvas, but a sprite swap will.

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

246 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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 do I set my canvas / camera to represent what will be put on phone screen? 0 Answers

UGUI: Buttons on scrollview don't always register touches 1 Answer

Canvas not loading on first click of button 0 Answers

Android UI push Multiple buttons Help 0 Answers

Possible for 10 canvas in 1 scene? 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