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
2
Question by Steven-Walker · Dec 13, 2010 at 11:22 PM · editor-scriptingnullreferenceexceptiondisplayprogress-bar

DisplayCancelableProgressBar NullReferenceException

I'm having trouble getting the progress bar to work. It does display and does show the progress, but it also results in a null reference exception that I can't figure out.

In my editor script during OnInspectorGUI, I'm calling this several times:

EditorUtility.DisplayProgressBar("My Task", "Operation...", progress);

At some point during execution, this error shows up:

NullReferenceException: Object reference not set to an instance of an object UnityEngine.GUIUtility.GetControlID (Int32 hint, FocusType focus) UnityEditor.InspectorWindow.OnGUI () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr,

System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)

Any ideas what could be wrong or what's missing? At this point I'm ready to give up and use some alternate method of showing progress.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by watsonsong · Mar 31, 2017 at 05:20 AM

I met the same problem, when using the DisplayCancelableProgressBar. If i remove it, there is no null exception throw any more.

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
0

Answer by rgrandguillot · Mar 20, 2018 at 09:58 PM

I came across the same issue after upgrading to Unity 2017.3. Before that, with Unity 5.6, DisplayCancelableProgressBar was acting perfectly with no error.

Comment
Add comment · Show 3 · 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 Xarbrough · Mar 20, 2018 at 10:18 PM 1
Share

Have you filed a bug report for Unity? I remember having a similar issue, but forgot about it, so I doubt Unity is aware of it.

avatar image Bunny83 Xarbrough · Mar 20, 2018 at 10:41 PM 2
Share

I never had any problems with it. However the example shown in the documentaion doesn't make too much sense. THe DisplayCancelableProgressBar is meant to be used in a blocking execution. It's basically a modal window. If the process is started from within a OnGUI block you may want to call ExitGUI once the process has completed. So a typical usecase would be

 void OnGUI()
 {
     if (GUILayout.Button("Do heavy work"))
     {
         for(int i = 0; i < 100000; i++)
         {
             if (i%100 == 0 && EditorUtility.DisplayCancelableProgressBar("", "", (float)i/100000))
                 break;
             // do some heavy work here
             System.Thread.Sleep(10);
         }
         EditorUtility.ClearProgressBar();
         EditorGUIUtility.ExitGUI();
     }
 }

So when you press the "Do heavy work" button you basically block the main thread until your work is done. The CancelableProgressBar allows the user to interrupt that process.

avatar image rgrandguillot Bunny83 · Mar 24, 2018 at 11:36 AM 0
Share

Fantastic! The EditorGUIUtility.ExitGUI(); solves the problem. Thanks a lot.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Editor-Script: NullReference after simple script execution 3 Answers

How do I resize the Lightmap Array via Editor Script? 1 Answer

Editor Window/Scriptable object - null problem 2 Answers

Changing the editor display aspect ratio/fixed resolution programmatically 0 Answers

AddComponent giving NullReferenceException in Editor script 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