Created
January 18, 2023 13:21
-
-
Save nicoplv/9e4b56d490da2959ee600e920e740e3e to your computer and use it in GitHub Desktop.
An helper to be able to use the Unity Progress Bar with background or async operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[UnityEditor.InitializeOnLoad] | |
public class ProgressBarHelper | |
{ | |
#region Methods | |
protected static List<Action> actions = new List<Action>(); | |
static ProgressBarHelper() | |
{ | |
UnityEditor.EditorApplication.update += Update; | |
} | |
private static void Update() | |
{ | |
while(actions.Count > 0) | |
{ | |
actions[0].Invoke(); | |
actions.RemoveAt(0); | |
} | |
} | |
public static void DisplayProgressBar(string _title, string _description, float _progress) | |
{ | |
actions.Add(() => EditorUtility.DisplayProgressBar(_title, _description, _progress)); | |
} | |
public static void ClearProgressBar() | |
{ | |
actions.Add(() => EditorUtility.ClearProgressBar()); | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment