using UnityEditor; using UnityEngine.UIElements; #if UNITY_2021_1_OR_NEWER using UnityEditor.PackageManager.UI.Internal; #else using UnityEditor.PackageManager.UI; #endif using System.Linq; using UnityEngine; using System.Text.RegularExpressions; using UnityEditor.Scripting.ScriptCompilation; using static UnityEditor.PlayerSettings; namespace Cocklebur { internal class GitPackageInstallationWindow : VisualElement { //################################ // Constant or Static Members. //################################ static string ResourcesPath => UpmGitUtils.GetInPackagePath("Editor/Resources/"); static string TemplatePath => ResourcesPath + "GitPackageInstallationWindow.uxml"; static string StylePath => ResourcesPath + "GitPackageInstallationWindow.uss"; public static bool IsResourceReady() { return EditorGUIUtility.Load(TemplatePath) && EditorGUIUtility.Load(StylePath); } //################################ // Public Members. //################################ public GitPackageInstallationWindow() { VisualTreeAsset asset = EditorGUIUtility.Load(TemplatePath) as VisualTreeAsset; var root = asset.CloneTree(); styleSheets.Add(AssetDatabase.LoadAssetAtPath(StylePath)); // Add ui elements and class (for miximize). AddToClassList("maximized"); root.AddToClassList("maximized"); root.AddToClassList("installationWindow"); root.AddToClassList(EditorGUIUtility.isProSkin ? "dark" : "right"); Add(root); _rootContainer = root.Q("rootContainer"); // Find ui elements. _loadingSpinner = new LoadingSpinner(); root.Q("titleContainer").Add(_loadingSpinner); _urlContainer = root.Q("urlContainer"); _repoUrlText = root.Q("repoUrlText"); _findVersionsButton = root.Q