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 Jiraiyah · Nov 28, 2015 at 04:49 PM · editorprogress barbuiltinbuilt-in

using editor's built in progress bar

when you bake the light map for example, there is a progress bar on the lower right side of the editor window, is there anyway to use it from custom editor scripts? I don't want to create my own progress bar but to use the same one unity already has. is there any way to do it? thanks

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
2
Best Answer

Answer by Bunny83 · Nov 28, 2015 at 07:48 PM

The progressbar of the lightmap baking process inside the "status bar" is handled by an internal class called AppStatusBar. It's a GUIView that is part of the main application window. The progressbar is controlled by another internal class called AsyncProgressBar. This class just has external properties. The Editor application itself is still a native application so there's no way to access those properties, even with reflection .

The built-in ways to display a progressbar are:

  • EditorUtility.DisplayProgressBar or EditorUtility.DisplayCancelableProgressBar and when done use EditorUtility.ClearProgressBar

  • Inside a custom inspector or editor window you can use EditorGUI.ProgressBar

edit
I just had another look at the internal "AsyncProgressBar" class and yes, it seems @Jiraiyah is right. I somehow overlooked that "Display" method since all properties an methods are declared external i didn't think there was any way. However it seems to work pretty much the same way the EditorUtility progressbar works. I've quickly written the following class and it seems to work. But keep in mind that this is not a clean solution since it uses reflection to access an internal class. It's not ment to be used and can change in the future and might even break other things.

 using UnityEngine;
 using UnityEditor;
 using System.Linq;
 using System.Reflection;
 
 public static class EditorProgressBar
 {
     static MethodInfo m_Display = null;
     static MethodInfo m_Clear = null;
     static EditorProgressBar()
     {
         var type = typeof(Editor).Assembly.GetTypes().Where(t => t.Name == "AsyncProgressBar").FirstOrDefault();
         if (type != null)
         {
             m_Display = type.GetMethod("Display");
             m_Clear = type.GetMethod("Clear");
         }
     }
 
     public static void ShowProgressBar(string aText, float aProgress)
     {
         if (m_Display != null)
             m_Display.Invoke(null, new object[] { aText, aProgress });
     }
     public static void ClearProgressBar()
     {
         if (m_Clear != null)
             m_Clear.Invoke(null, null);
     }
 }



Comment
Add comment · Show 1 · 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 Jiraiyah · Nov 29, 2015 at 06:09 AM 0
Share

Gave 5 points for the code sir, thanks for help.

avatar image
1

Answer by Jiraiyah · Nov 29, 2015 at 01:16 AM

Hmm AsyncProgressBar has a public static extern method called Diplay that accepts string and float, why wouldn't I be able to invoke that method via reflection ? (new to reflection stuff so it may be a noob question) is that because it is extern?

alt text

isn't this the method responsible of drawing the progress there?


bhv845k.png (20.7 kB)
Comment
Add comment · Show 1 · 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 Bunny83 · Nov 29, 2015 at 04:55 AM 0
Share

Yes, you're right. I've edited my answer.

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

33 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

Related Questions

Unity Preferences' Large Heading Font 2 Answers

Problem With Javascript to Built-in Array 0 Answers

GetAssetPath returning incomplete path for default materials 1 Answer

How to get every public variables(Including Buit-in) from a script in c# 4 Answers

How to allow custom classes, to be a variant of sealed unity classes, and allow selecting either, in existing inspectors. 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