arenos-nexus/Arenos Nexus/Library/PackageCache/com.unity.collab-proxy@ab839cc7d2ad/Editor/UI/Progress/LoadingSpinner.cs

41 lines
1.2 KiB
C#
Raw Normal View History

2025-09-25 22:01:28 +02:00
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI.Progress
{
internal static class LoadingSpinner
{
internal static void OnGUI(
float progressPercent,
string progressTooltip = null)
{
Matrix4x4 oldMatrix = GUI.matrix;
Rect layoutRect = GUILayoutUtility.GetRect(
SPINNER_SIZE, SPINNER_SIZE);
Rect position = new Rect(
layoutRect.x + (layoutRect.width - SPINNER_SIZE) / 2,
layoutRect.y + (layoutRect.height - SPINNER_SIZE) / 2,
SPINNER_SIZE, SPINNER_SIZE);
Vector2 pivot = new Vector2(
position.x + SPINNER_SIZE / 2f,
position.y + SPINNER_SIZE / 2f);
int rotation = (int)(360 * progressPercent);
GUIUtility.RotateAroundPivot(rotation, pivot);
GUI.Label(
position,
new GUIContent(
Images.GetImage(Images.Name.Loading),
progressTooltip),
UnityStyles.StatusBar.Icon);
GUI.matrix = oldMatrix;
}
const int SPINNER_SIZE = 16;
}
}