• 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
Question by LW · Sep 15, 2016 at 11:10 PM · c#editorinspectoreditor-scripting

How To Force an Inspector to Repaint

In an inspector I'm invoking a Coroutine. When the Coroutine finishes I want the Editor to Repaint(). However, calling Repaint() from the Coroutine's callback doesn't Repaint(). Is there a simple solution to this that I'm missing?

Thanks,

Comment

People who like this

0 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 Adam-Mechtley · Sep 16, 2016 at 08:24 AM 0
Share

How are you invoking your coroutine? I'm assuming you have verified that it actually finishes.

avatar image LW · Sep 16, 2016 at 03:46 PM 0
Share

@Adam-Mechtley, the only way I know how to invoke a MonoBehaviour::StartCoroutine() is with an instance of a component bound to a GameObject- in this instance, the Editor.target of the custom inspector I'm using.

However, @Glurth's insight pointed me toward the actual issue (how the editor interprets yield functionality).

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by LW · Sep 16, 2016 at 03:55 PM

I've written a short workaround for how the Unity editor handles yield instructions within the editor space (shown below):

 protected System.Collections.IEnumerator CoQuery()
 {
     bool bStillWorkingOnSomething = true;
 
 #if UNITY_EDITOR
 
     if (!Application.isPlaying)
     {
         while (bStillWorkingOnSomething) 
         {
             /* When done doing what your doing... */
             bStillWorkingOnSomething = false;
         }
     }
     else
     {
 
 #endif // UNITY_EDITOR
     
         yield return new WaitForSeconds(1); // Or something similar...
     
 #if UNITY_EDITOR
 
     }
 
 #endif // UNITY_EDITOR
 }


Hopefully, this can help someone in the future.

Comment

People who like this

0 Show 0 · 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

Answer by Glurth · Sep 16, 2016 at 01:04 AM

the only way I've found to do this, consistantly, is to override the Editor's RequiresContantRepaint function eg

 override public bool RequiresConstantRepaint() { return (repaintCondition1 || repaintCondition2); }
Comment
MrBrux
Supergeek
aka3eka

People who like this

3 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 LW · Sep 16, 2016 at 03:42 PM 0
Share

Ty @Glurth, you helped me realize the problem wasn't where I was ignorantly looking.

The issue wasn't with repainting rather it has to do with how Unity utilizes yield instructions.

avatar image Supergeek · Feb 20, 2018 at 09:52 PM 0
Share

Thank you so much for this. This is so much simpler than the Best Answer that the OP posted! I've been trying to get this Repaint to work for 30 minutes.

avatar image LW Supergeek · Feb 20, 2018 at 10:06 PM 0
Share

A little old but... yeah, if you read what I wrote the problem wasn't in repainting but in how the yield instruction was handled in editor.

If you just need to repaint you override RequiresConstantRepaint.

If you need to query until you get a response you would use what I wrote or something similar.

avatar image Supergeek LW · Feb 20, 2018 at 10:23 PM 0
Share

Absolutely! I didn't mean to denigrate your answer, but it was a bit over my head! The one-liner suits my needs for now. Once I become more advanced with Unity and create more sophisticated custom editor windows, I'll revisit this to get a better understanding.

avatar image

Answer by LW · Sep 16, 2016 at 02:07 PM

Wow, I love how I'm not good enough to comment on a reply in a thread I've started....

@Glurth, I've tried to override UnityEditor.Engine::RequiresConstantRepaint() but that doesn't get the update to occur. Which makes me think this isn't the actual problem.... I need to do more digging.

I will post what I find.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

227 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

Related Questions

Custom Editor Script resets values on Play 1 Answer

How to access one class instance in editor script? 1 Answer

Editor Script, Index Out of Range Exception after Play 1 Answer

Gizmos.DrawLine is dissapearing after returning to editor after Playing the scene 0 Answers

TexturePropertySingleLine in Editor class 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