Skip to content

Instantly share code, notes, and snippets.

@shanecelis
Last active August 31, 2022 05:43
Show Gist options
  • Save shanecelis/7a8db9a316ee90b939d61fd621a97269 to your computer and use it in GitHub Desktop.
Save shanecelis/7a8db9a316ee90b939d61fd621a97269 to your computer and use it in GitHub Desktop.
Exposes runtime progress bar for UIToolkit for Unity 2020.3.
/** Using UIElements and want to use UIToolkit's progress bar at runtime? Hope,
you're using Unity 2021.1 or later. If you aren't, you can expose the
progress bar in Unity 2020.3 and perhaps even earlier versions (not tested).
`com.unity.ui v1.0.0-preview.18` uses the following #ifdef for the
`ProgressBar` class[1]:
```
#if !UIE_PACKAGE || UNITY_2021_1_OR_NEWER
```
We use our own #ifdef for 2020.3 or later but exclude it for 2021 and later
so it doesn't conflict with `com.unity.ui`'s actual ProgressBar.
[1]: https://github.com/needle-mirror/com.unity.ui/blob/9837807be0ff6bdf12df2e2bed0cbcef7936e3d9/Core/Controls/ProgressBar.cs
*/
#if !UIE_PACKAGE || UNITY_2020_3_OR_NEWER && ! UNITY_2021_1_OR_NEWER
using UnityEngine.Scripting.APIUpdating;
namespace UnityEngine.UIElements
{
/// <summary>
/// A control that displays the progress between a lower and upper bound value.
/// </summary>
[MovedFrom(true, "UnityEditor.UIElements", "UnityEditor.UIElementsModule")]
public class ProgressBar : AbstractProgressBar
{
/// <undoc/>
public new class UxmlFactory : UxmlFactory<ProgressBar, UxmlTraits> {}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment