Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by DaiMangouDev · Sep 04, 2015 at 05:13 PM · c#editoreditorwindowrepaint

When is the best time to call Repaint(); in an editor window

In order to update the UI , I need to call Repaint(); , or EditorWindow.focusedWindow.Repaint();

However In the case of a simple button with an hover effect . If that button with an hover effect is being rendered in the editor window and I am not calling Repaint(); in my EditorWindow script , then I wont see the hover effect on the button when I move my cursor over it unless I leave the cursor in one position for a second or so ; so when the window automatically updates itself.

Right now I call Reapint(); whenever the mouse is down in the EditorWindow , but that too is not a good fix , as it will never allow for redrawing of UI if the cursor hovers over a button with an hover effect as i mentioned before.

I cant constantly call Reapint(); , it would make my editor window slow, but I would constantly have an updated UI .

I have no idea of how to work around this . When exactly do I call repaint ?

I really really dont want to constantly repaint my editor window when it in focus and there is no interaction with the UI because I will end up with more pressure on my CUP .

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

1 Reply

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

Answer by BMayne · Sep 04, 2015 at 05:46 PM

Hey there,

You can totally call repaint if you want to every frame, this is what it's there for. The only reason it does not do it by default is the fact that editors are mostly static. If your editor is running slow you should most likely break it up anyway.

Cheers,

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 DaiMangouDev · Sep 04, 2015 at 06:16 PM 0
Share

I really really appreciate the solid concise answer. So i'm i'm seeing too much overhead then I need to revise my code .

I will take your word and go with through with calling Repaint(); every frame.

avatar image BMayne · Sep 04, 2015 at 06:27 PM 1
Share

Sometimes for larger editor I break stuff into tabs but this completely depends on the type of tool you are making. Also try to break away from creating stuff in OnGUI or any thing like GetComponent. On GUI gets called a ton of times per frame and this can really bog you down.

Cheers,

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

28 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

Related Questions

Listen to Keyboard Events on EditorWindow 1 Answer

Initialising List array for use in a custom Editor 1 Answer

Editor Windows - Where to get started? 1 Answer

OnGui elements as objects? 2 Answers

Close script tab in VS, from script 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