From 9f4756171d60125fb289dad42ee24a12bb7bdd43 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 13 Sep 2019 14:20:55 -0400 Subject: [PATCH] Proper UPM registry support (#317) * updated package information * Added legacy xr input helper package dependancy * Added some more keywords * Removed all the package utilities for the Git process * removed unused reference * updated seed package to install registry and core package * Cleaner * updated registry url to use subdomain --- XRTK-Core/Assets/SymbolicLinkSettings.asset | 3 - .../XRTK.Seed/MixedRealityPackageSeed.cs | 79 ++---- .../Definitions/MixedRealityPackageInfo.cs | 116 -------- .../MixedRealityPackageInfo.cs.meta | 11 - .../MixedRealityPackageSettings.cs | 45 ---- .../MixedRealityPackageSettings.cs.meta | 11 - .../Inspectors/MixedRealityPreferences.cs | 60 ----- .../Inspectors/Utilities/Packages.meta | 8 - .../MixedRealityPackageSettingsInspector.cs | 29 -- ...xedRealityPackageSettingsInspector.cs.meta | 11 - .../Packages/MixedRealityPackageUtilities.cs | 253 ------------------ .../MixedRealityPackageUtilities.cs.meta | 11 - .../Packages/MixedRealityPackagesWindow.cs | 150 ----------- .../MixedRealityPackagesWindow.cs.meta | 11 - .../Utilities/SymbolicLinks/SymbolicLinker.cs | 6 +- .../SymbolicLinks/SymbolicLinkerWindow.cs | 3 - XRTK-Core/Packages/com.xrtk.core/XRTK.asmdef | 6 +- XRTK-Core/Packages/com.xrtk.core/package.json | 26 +- XRTK-Core/Packages/manifest.json | 9 + 19 files changed, 57 insertions(+), 791 deletions(-) delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs.meta delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs.meta delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages.meta delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs.meta delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs.meta delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs delete mode 100644 XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs.meta diff --git a/XRTK-Core/Assets/SymbolicLinkSettings.asset b/XRTK-Core/Assets/SymbolicLinkSettings.asset index 35556d8cb..591c726c7 100644 --- a/XRTK-Core/Assets/SymbolicLinkSettings.asset +++ b/XRTK-Core/Assets/SymbolicLinkSettings.asset @@ -16,9 +16,6 @@ MonoBehaviour: - sourceRelativePath: /Submodules/WindowsMixedReality/XRTK.WindowsMixedReality/Packages/com.xrtk.wmr targetRelativePath: /XRTK-Core/Packages/com.xrtk.wmr isActive: 1 - - sourceRelativePath: /Submodules/UpmGitExtension/XRTK.UpmGitExtension/Packages/com.xrtk.upm-git-extension - targetRelativePath: /XRTK-Core/Packages/com.xrtk.upm-git-extension - isActive: 1 - sourceRelativePath: /Submodules/Lumin/XRTK.Lumin/Packages/com.xrtk.lumin targetRelativePath: /XRTK-Core/Packages/com.xrtk.lumin isActive: 1 diff --git a/XRTK-Core/Assets/XRTK.Seed/MixedRealityPackageSeed.cs b/XRTK-Core/Assets/XRTK.Seed/MixedRealityPackageSeed.cs index 9d1109c37..eaf8b68dc 100644 --- a/XRTK-Core/Assets/XRTK.Seed/MixedRealityPackageSeed.cs +++ b/XRTK-Core/Assets/XRTK.Seed/MixedRealityPackageSeed.cs @@ -2,13 +2,11 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using System; -using System.Diagnostics; -using System.Linq; +using System.IO; using System.Reflection; -using System.Text.RegularExpressions; using UnityEditor; using UnityEditor.PackageManager; -using Debug = UnityEngine.Debug; +using UnityEngine; namespace XRTK.Seed { @@ -21,7 +19,17 @@ namespace XRTK.Seed [InitializeOnLoad] public class MixedRealityPackageSeed { - private const string Repository = "https://github.com/XRTK/XRTK-Core.git"; + private const string ScopedRegistryEntry = @"{ + ""scopedRegistries"": [ + { + ""name"": ""XRTK"", + ""url"": ""http://upm.xrtk.io:4873/"", + ""scopes"": [ + ""com.xrtk"" + ] + } + ], +"; static MixedRealityPackageSeed() { @@ -44,62 +52,27 @@ private static void Run() { if (assembly == null) { - var process = new Process - { - StartInfo = new ProcessStartInfo - { - WindowStyle = ProcessWindowStyle.Normal, - CreateNoWindow = true, - UseShellExecute = false, - RedirectStandardOutput = true, - RedirectStandardError = true, - FileName = "cmd.exe", - Arguments = $"/C git ls-remote --tags {Repository}" - } - }; - - var tag = "0.1.3"; + var manifestFilePath = $"{Directory.GetParent(Application.dataPath)}\\Packages\\manifest.json"; - try + if (File.Exists(manifestFilePath)) { - if (process.Start()) - { - var error = process.StandardError.ReadToEnd(); + var text = File.ReadAllText(manifestFilePath); - if (string.IsNullOrEmpty(error)) - { - var output = process.StandardOutput.ReadToEnd(); - - var tags = output.Split('\n') - .Select(t => Regex.Match(t, "(\\d*\\.\\d*\\.\\d*)")) - .Where(match => match.Success) - .Select(match => new Version(match.Value)) - .OrderBy(version => version); - - tag = tags.LastOrDefault()?.ToString(); - } - else - { - Debug.LogError(error); - } - - process.WaitForExit(); - process.Close(); - process.Dispose(); - } - else + if (!text.Contains("XRTK")) { - Debug.LogError("Failed to get remote tags for the XRTK package!"); + text = text.TrimStart('{'); + text = $"{ScopedRegistryEntry}{text}"; } + + File.WriteAllText(manifestFilePath, text); + + Client.Add("com.xrtk.core"); + AssetDatabase.DeleteAsset("Assets/XRTK.Seed"); } - catch (Exception e) + else { - Debug.LogError(e.Message); + Debug.LogError("Failed to install XRTK, couldn't find the project manifest!"); } - - Client.Add($"com.xrtk.core@{Repository}#{tag}"); - EditorUtility.DisplayProgressBar("Installing the Mixed Reality Toolkit", "Resolving packages...", 0.1f); - AssetDatabase.DeleteAsset("Assets/XRTK.Seed"); } } } diff --git a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs b/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs deleted file mode 100644 index a9aabac41..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) XRTK. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -using System; -using UnityEngine; - -namespace XRTK.Definitions -{ - /// - /// The container for defining a xrtk upm package. - /// - [Serializable] - public struct MixedRealityPackageInfo - { - /// - /// Constructor. - /// - /// Name of the package: com.company.package - /// Friendly display name of the package. - /// Remote repository uri. - /// Is this package required? - internal MixedRealityPackageInfo(string name, string displayName, string uri, bool isRequiredPackage = false) - { - this.name = name; - this.displayName = displayName; - this.uri = uri; - this.isRequiredPackage = isRequiredPackage; - isDefaultPackage = true; - isEnabled = true; - } - - [SerializeField] - [Tooltip("The package name\n\"com.company.product\"")] - private string name; - - /// - /// The package name - /// - /// - /// com.company.product - /// - public string Name - { - get => name; - internal set => name = value; - } - - [SerializeField] - [Tooltip("The package display name.")] - private string displayName; - - /// - /// "The package display name - /// - public string DisplayName - { - get => displayName; - internal set => displayName = value; - } - - [SerializeField] - [Tooltip("The package url\n\"https://githubcom/username/project.git\"")] - private string uri; - - /// - /// The package url. - /// - /// - /// https://githubcom/username/project.git - /// - public string Uri - { - get => uri; - internal set => uri = value; - } - - [SerializeField] - [Tooltip("This package is installed by the XRTK by default?")] - private bool isDefaultPackage; - - /// - /// This package is installed by the XRTK by default? - /// - public bool IsDefaultPackage - { - get => isDefaultPackage; - internal set => isDefaultPackage = value; - } - - [SerializeField] - [Tooltip("This package is required by the XRTK.")] - private bool isRequiredPackage; - - /// - /// This package is required by the xrtk. - /// - public bool IsRequiredPackage - { - get => isRequiredPackage; - internal set => isRequiredPackage = value; - } - - [SerializeField] - [Tooltip("Is this package currently enabled in the project?")] - private bool isEnabled; - - /// - /// Is this package currently enabled in the project? - /// - public bool IsEnabled - { - get => isEnabled; - internal set => isEnabled = value; - } - } -} \ No newline at end of file diff --git a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs.meta b/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs.meta deleted file mode 100644 index c4bd9a7d4..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1a148b4bc8dd466b964eaf7fdb52f846 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 8ac5213854cf4dbabd140decf8df1946, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs b/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs deleted file mode 100644 index 1bc6205a4..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) XRTK. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -using UnityEngine; - -namespace XRTK.Definitions -{ - /// - /// Data container for holding the settings for the upm packages associated with the XRTK. - /// - public class MixedRealityPackageSettings : ScriptableObject - { - [SerializeField] - [Tooltip("Known xrtk packages in upm.")] - private MixedRealityPackageInfo[] mixedRealityPackages = - { - new MixedRealityPackageInfo("com.xrtk.upm-git-extension", "XRTK.UpmGitExtension", "https://github.com/XRTK/UpmGitExtension.git", isRequiredPackage: true), - new MixedRealityPackageInfo("com.xrtk.wmr", "XRTK.WindowsMixedReality", "https://github.com/XRTK/WindowsMixedReality.git"), - new MixedRealityPackageInfo("com.xrtk.lumin", "XRTK.Lumin", "https://github.com/XRTK/Lumin.git"), - new MixedRealityPackageInfo("com.xrtk.sdk", "XRTK.SDK", "https://github.com/XRTK/SDK.git"), - new MixedRealityPackageInfo("com.xrtk.oculus", "XRTK.Oculus", "https://github.com/XRTK/Oculus.git"), - }; - - /// - /// Known XRTK packages in upm. - /// - public MixedRealityPackageInfo[] MixedRealityPackages - { - get => mixedRealityPackages; - internal set - { - mixedRealityPackages = value; -#if UNITY_EDITOR - UnityEditor.EditorUtility.SetDirty(this); - UnityEditor.AssetDatabase.SaveAssets(); - - if (!UnityEditor.EditorApplication.isUpdating) - { - UnityEditor.AssetDatabase.Refresh(UnityEditor.ImportAssetOptions.ForceUpdate); - } -#endif - } - } - } -} diff --git a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs.meta b/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs.meta deleted file mode 100644 index c246994fe..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Definitions/MixedRealityPackageSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 15c83ddfe69772747b49823a06d56d32 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 6e2e9d716bbb4d8382bd53f11996b90e, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/MixedRealityPreferences.cs b/XRTK-Core/Packages/com.xrtk.core/Inspectors/MixedRealityPreferences.cs index e3f6dfc46..7e2159d47 100644 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/MixedRealityPreferences.cs +++ b/XRTK-Core/Packages/com.xrtk.core/Inspectors/MixedRealityPreferences.cs @@ -6,9 +6,7 @@ using System.Linq; using UnityEditor; using UnityEngine; -using XRTK.Definitions; using XRTK.Extensions.EditorClassExtensions; -using XRTK.Inspectors.Utilities.Packages; using XRTK.Inspectors.Utilities.SymbolicLinks; using XRTK.Utilities.Editor; @@ -191,41 +189,6 @@ public static bool AutoLoadSymbolicLinks #endregion Symbolic Link Preferences - #region Package Preferences - - private static bool isPackageSettingsPathLoaded; - private static string packageSettingsPath = string.Empty; - - /// - /// The path to the package settings found for this project. - /// - public static string PackageSettingsPath - { - get - { - if (!isPackageSettingsPathLoaded) - { - symbolicLinkSettingsPath = EditorPreferences.Get("_PackageSettingsPath", string.Empty); - isPackageSettingsPathLoaded = true; - } - - if (!EditorApplication.isUpdating && - string.IsNullOrEmpty(packageSettingsPath)) - { - packageSettingsPath = AssetDatabase - .FindAssets($"t:{typeof(MixedRealityPackageSettings).Name}") - .Select(AssetDatabase.GUIDToAssetPath) - .OrderBy(x => x) - .FirstOrDefault(); - } - - return packageSettingsPath; - } - set => EditorPreferences.Set("_PackageSettingsPath", packageSettingsPath = value); - } - - #endregion Package Prefernces - #region Debug Packages private static readonly GUIContent DebugUpmContent = new GUIContent("Debug package loading", "Enable or disable the debug information for package loading.\n\nThis setting only applies to the currently running project."); @@ -365,29 +328,6 @@ private static void OnPreferencesGui(string searchContext) DebugPackageInfo = debugPackageInfo; } - EditorGUI.BeginChangeCheck(); - var packageSettings = EditorGUILayout.ObjectField("Package Settings", MixedRealityPackageUtilities.PackageSettings, typeof(MixedRealityPackageSettings), false) as MixedRealityPackageSettings; - - if (EditorGUI.EndChangeCheck()) - { - if (packageSettings != null) - { - var shouldSync = string.IsNullOrEmpty(PackageSettingsPath); - PackageSettingsPath = AssetDatabase.GetAssetPath(packageSettings); - MixedRealityPackageUtilities.PackageSettings = AssetDatabase.LoadAssetAtPath(PackageSettingsPath); - - if (shouldSync) - { - EditorApplication.delayCall += MixedRealityPackageUtilities.CheckPackageManifest; - } - } - else - { - PackageSettingsPath = string.Empty; - MixedRealityPackageUtilities.PackageSettings = null; - } - } - EditorGUIUtility.labelWidth = prevLabelWidth; } diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages.meta b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages.meta deleted file mode 100644 index 6ac4e8516..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8b92b3aed1da0fa4db0141421f30b376 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs deleted file mode 100644 index d21cf96cd..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) XRTK. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -using UnityEditor; -using UnityEngine; -using XRTK.Definitions; - -namespace XRTK.Inspectors.Utilities.Packages -{ - [CustomEditor(typeof(MixedRealityPackageSettings))] - public class MixedRealityPackageSettingsInspector : Editor - { - private SerializedProperty mixedRealityPackages; - - private void OnEnable() - { - mixedRealityPackages = serializedObject.FindProperty("mixedRealityPackages"); - } - - public override void OnInspectorGUI() - { - MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo(); - GUI.enabled = !MixedRealityPreferences.LockProfiles; - serializedObject.Update(); - EditorGUILayout.PropertyField(mixedRealityPackages, true); - serializedObject.ApplyModifiedProperties(); - } - } -} diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs.meta b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs.meta deleted file mode 100644 index afbadbbf5..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageSettingsInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 58310fd46ff58844fa2022330fd411e2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 8ac5213854cf4dbabd140decf8df1946, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs deleted file mode 100644 index ec1afd168..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) XRTK. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -using System; -using System.Linq; -using System.Threading.Tasks; -using UnityEditor; -using UnityEditor.PackageManager; -using UnityEngine; -using XRTK.Definitions; -using XRTK.Extensions.EditorClassExtensions; -using XRTK.Utilities.Async; -using PackageInfo = UnityEditor.PackageManager.PackageInfo; - -namespace XRTK.Inspectors.Utilities.Packages -{ - public static class MixedRealityPackageUtilities - { - /// - /// The Mixed Reality Toolkit's upm package settings. - /// - public static MixedRealityPackageSettings PackageSettings - { - get - { - if (EditorApplication.isUpdating) - { - return packageSettings; - } - - if (packageSettings == null && - !string.IsNullOrEmpty(MixedRealityPreferences.PackageSettingsPath)) - { - packageSettings = AssetDatabase.LoadAssetAtPath(MixedRealityPreferences.PackageSettingsPath); - } - - if (packageSettings == null) - { - packageSettings = ScriptableObject.CreateInstance(nameof(MixedRealityPackageSettings)) as MixedRealityPackageSettings; - packageSettings.CreateAsset("Assets/XRTK.Generated/CustomProfiles"); - } - - return packageSettings; - } - internal set => packageSettings = value; - } - - private static MixedRealityPackageSettings packageSettings; - - /// - /// Is the package utility running a check? - /// - public static bool IsRunningCheck { get; private set; } - - /// - /// Debug the package utility. - /// - public static bool DebugEnabled - { - get => MixedRealityPreferences.DebugPackageInfo; - set => MixedRealityPreferences.DebugPackageInfo = value; - } - - private static Tuple[] currentPackages; - - /// - /// Ensures the package manifest is up to date. - /// - public static async void CheckPackageManifest() - { - if (IsRunningCheck || - EditorApplication.isPlayingOrWillChangePlaymode || - Application.isBatchMode) - { - return; - } - - if (PackageSettings == null) - { - if (EditorApplication.isUpdating) - { - EditorApplication.delayCall += CheckPackageManifest; - return; - } - - Debug.LogError("Failed to find Package Settings!"); - return; - } - - IsRunningCheck = true; - - if (DebugEnabled) - { - Debug.Log("Checking packages..."); - } - - if (PackageSettings != null) - { - Tuple[] installedPackages; - - try - { - installedPackages = await GetCurrentMixedRealityPackagesAsync(); - } - catch (Exception e) - { - Debug.LogError($"{e.Message}\n{e.StackTrace}"); - IsRunningCheck = false; - return; - } - - foreach (var installedPackage in installedPackages) - { - CheckPackage(installedPackage); - } - } - else - { - Debug.LogWarning("Failed to find package settings."); - } - - if (DebugEnabled) - { - Debug.Log("Check complete!"); - } - - IsRunningCheck = false; - } - - private static async void CheckPackage(Tuple installedPackage) - { - (MixedRealityPackageInfo package, bool isInstalled) = installedPackage; - - if (DebugEnabled) - { - Debug.Log($"{package.Name} | Enabled? {package.IsEnabled} | Installed? {isInstalled}"); - } - - if (package.IsRequiredPackage && !isInstalled || - (package.IsDefaultPackage && package.IsEnabled && !isInstalled)) - { - try - { - await AddPackageAsync(package); - } - catch (Exception e) - { - Debug.LogError($"{e.Message}\n{e.StackTrace}"); - } - } - else if (!package.IsEnabled && isInstalled) - { - try - { - await RemovePackageAsync(package); - } - catch (Exception e) - { - Debug.LogError($"{e.Message}\n{e.StackTrace}"); - } - } - } - - /// - /// Validates the currently installed upm xrtk packages. - /// - internal static async void ValidatePackages() - { - try - { - await GetCurrentMixedRealityPackagesAsync(); - } - catch (Exception e) - { - Debug.LogError($"{e.Message}\n{e.StackTrace}"); - } - } - - /// - /// Returns the currently installed upm xrtk packages. - /// - /// A can occur if the packages are not returned in 10 seconds. - internal static async Task[]> GetCurrentMixedRealityPackagesAsync() - { - var packageCount = PackageSettings.MixedRealityPackages.Length; - currentPackages = new Tuple[packageCount]; - var upmPackageListRequest = Client.List(true); - - await upmPackageListRequest.WaitUntil(request => request.IsCompleted, timeout: 30); - - var installedPackages = PackageSettings.MixedRealityPackages - .Select(package => upmPackageListRequest.Result? - .FirstOrDefault(packageInfo => packageInfo.name.Equals(package.Name))) - .Where(upmPackage => upmPackage != null) - .ToList(); - - for (var i = 0; i < PackageSettings.MixedRealityPackages.Length; i++) - { - var package = PackageSettings.MixedRealityPackages[i]; - var isInstalled = installedPackages.Any(UpmCheck); - - currentPackages[i] = new Tuple(package, isInstalled); - - bool UpmCheck(PackageInfo packageInfo) => packageInfo != null && packageInfo.name.Equals(package.Name); - } - - return currentPackages; - } - - private static async Task AddPackageAsync(MixedRealityPackageInfo packageInfo) - { - var versionSeparator = new[] { '.' }; - var tag = (await GitUtilities.GetAllTagsFromRemoteAsync(packageInfo.Uri)) - .OrderBy(value => int.Parse(value.Split(versionSeparator)[0])) // Major - .ThenBy(value => int.Parse(value.Split(versionSeparator)[1])) // Minor - .ThenBy(value => int.Parse(value.Split(versionSeparator)[2])) // Revision - .LastOrDefault(); - var addRequest = Client.Add($"{packageInfo.Name}@{packageInfo.Uri}#{tag}"); - - await addRequest.WaitUntil(request => request.IsCompleted, timeout: 30); - - if (addRequest.Status == StatusCode.Success) - { - if (DebugEnabled) - { - Debug.Log($"successfully added {packageInfo.Name}@{addRequest.Result.packageId}"); - } - } - else - { - Debug.LogError($"Package Error({addRequest.Error?.errorCode}): {addRequest.Error?.message}"); - } - } - - private static async Task RemovePackageAsync(MixedRealityPackageInfo packageInfo) - { - var removeRequest = Client.Remove($"{packageInfo.Name}"); - await removeRequest.WaitUntil(request => request.IsCompleted, timeout: 30); - - if (removeRequest.Status == StatusCode.Success) - { - if (DebugEnabled) - { - Debug.Log($"successfully removed {packageInfo.Name}"); - } - } - else if (removeRequest.Error?.errorCode != ErrorCode.NotFound) - { - Debug.LogError($"Package Error({removeRequest.Error?.errorCode}): {removeRequest.Error?.message}"); - } - } - } -} diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs.meta b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs.meta deleted file mode 100644 index b942b1a5d..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackageUtilities.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 50b41b377b82387439b64c9a3e68ed99 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 8ac5213854cf4dbabd140decf8df1946, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs deleted file mode 100644 index 2e05bbf1d..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) XRTK. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -using System; -using System.Linq; -using UnityEditor; -using UnityEngine; -using XRTK.Definitions; -using XRTK.Utilities.Editor; - -namespace XRTK.Inspectors.Utilities.Packages -{ - public class MixedRealityPackagesWindow : EditorWindow - { - private static MixedRealityPackagesWindow window; - private static Tuple[] packages; - private static bool[] isPackageEnabled; - private static bool isError; - - [MenuItem("Mixed Reality Toolkit/Packages...", true, 99)] - public static bool OpenPackagesWindowValidation() - { - return !MixedRealityPackageUtilities.IsRunningCheck; - } - - [MenuItem("Mixed Reality Toolkit/Packages...", false, 99)] - public static async void OpenPackagesWindow() - { - if (window != null) { window.Close(); } - - window = CreateInstance(typeof(MixedRealityPackagesWindow)) as MixedRealityPackagesWindow; - Debug.Assert(window != null); - window.titleContent = new GUIContent("XRTK UPM Packages"); - window.minSize = new Vector2(288, 320); - isError = false; - window.ShowUtility(); - - try - { - packages = await MixedRealityPackageUtilities.GetCurrentMixedRealityPackagesAsync(); - } - catch (Exception e) - { - Debug.LogError($"{e.Message}\n{e.StackTrace}"); - isError = true; - return; - } - - isPackageEnabled = new bool[packages.Length]; - - for (var i = 0; i < packages.Length; i++) - { - isPackageEnabled[i] = packages[i].Item1.IsEnabled; - } - } - - private void OnGUI() - { - if (window == null) { Close(); } - - EditorGUILayout.BeginVertical(); - MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo(); - EditorGUILayout.LabelField("Mixed Reality Toolkit Unity Package Manager"); - - if (packages == null) - { - EditorGUILayout.LabelField(isError ? "Failed to find packages!" : "Gathering Package data..."); - EditorGUILayout.EndVertical(); - return; - } - - var prevLabelWidth = EditorGUIUtility.labelWidth; - EditorGUIUtility.labelWidth = 256; - - for (var i = 0; i < packages.Length; i++) - { - (MixedRealityPackageInfo package, bool _) = packages[i]; - - GUI.enabled = !package.IsRequiredPackage; - EditorGUILayout.BeginHorizontal(); - GUILayout.Space(16); - isPackageEnabled[i] = EditorGUILayout.Toggle(isPackageEnabled[i], GUILayout.Width(12)); - var packageName = package.DisplayName.Replace("XRTK.", package.IsRequiredPackage ? " (Required) " : string.Empty); - EditorGUILayout.LabelField(new GUIContent(packageName)); - GUILayout.FlexibleSpace(); - EditorGUILayout.EndHorizontal(); - GUI.enabled = true; - } - - EditorGUIUtility.labelWidth = prevLabelWidth; - - if (GUILayout.Button("Apply")) - { - for (var i = 0; i < packages.Length; i++) - { - (MixedRealityPackageInfo package, bool isInstalled) = packages[i]; - - if (!isPackageEnabled[i] && isInstalled) - { - package.IsEnabled = false; - - if (MixedRealityPackageUtilities.DebugEnabled) - { - Debug.LogWarning($"{package.Name} isEnabled == false"); - } - } - - if (isPackageEnabled[i] && !isInstalled) - { - package.IsEnabled = true; - - if (MixedRealityPackageUtilities.DebugEnabled) - { - Debug.LogWarning($"{package.Name} isEnabled == true"); - } - } - - packages[i] = new Tuple(package, isInstalled); - } - - var newPackages = packages.Select(tuple => tuple.Item1).ToArray(); - MixedRealityPackageUtilities.PackageSettings.MixedRealityPackages = newPackages; - MixedRealityPackageUtilities.CheckPackageManifest(); - Close(); - } - - if (GUILayout.Button("Restore Default Packages")) - { - for (int i = 0; i < packages.Length; i++) - { - (MixedRealityPackageInfo package, bool isInstalled) = packages[i]; - - if (package.IsDefaultPackage) - { - package.IsEnabled = true; - } - - packages[i] = new Tuple(package, isInstalled); - } - - var newPackages = packages.Select(tuple => tuple.Item1).ToArray(); - MixedRealityPackageUtilities.PackageSettings.MixedRealityPackages = newPackages; - MixedRealityPackageUtilities.CheckPackageManifest(); - Close(); - } - - EditorGUILayout.EndVertical(); - } - } -} diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs.meta b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs.meta deleted file mode 100644 index 865da08d9..000000000 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/Packages/MixedRealityPackagesWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 435fa24426250b5438e340644f425a00 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 8ac5213854cf4dbabd140decf8df1946, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinker.cs b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinker.cs index 9efdbfacd..32986b5c3 100644 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinker.cs +++ b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinker.cs @@ -11,7 +11,6 @@ using UnityEditor.Callbacks; using UnityEngine; using XRTK.Extensions; -using XRTK.Inspectors.Utilities.Packages; using Debug = UnityEngine.Debug; namespace XRTK.Inspectors.Utilities.SymbolicLinks @@ -50,7 +49,7 @@ static SymbolicLinker() /// /// Is the sync task running? /// - public static bool IsSyncing => isRunningSync || MixedRealityPackageUtilities.IsRunningCheck; + public static bool IsSyncing => isRunningSync; /// /// Debug the symbolic linker utility. @@ -97,7 +96,6 @@ public static void RunSync(bool forceUpdate = false) if (!MixedRealityPreferences.AutoLoadSymbolicLinks && !forceUpdate) { - MixedRealityPackageUtilities.CheckPackageManifest(); return; } @@ -118,7 +116,6 @@ public static void RunSync(bool forceUpdate = false) } MixedRealityPreferences.AutoLoadSymbolicLinks = false; - MixedRealityPackageUtilities.CheckPackageManifest(); return; } @@ -199,7 +196,6 @@ public static void RunSync(bool forceUpdate = false) } EditorApplication.UnlockReloadAssemblies(); - MixedRealityPackageUtilities.CheckPackageManifest(); isRunningSync = false; } diff --git a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinkerWindow.cs b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinkerWindow.cs index 0b98a5aa0..3ce003113 100644 --- a/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinkerWindow.cs +++ b/XRTK-Core/Packages/com.xrtk.core/Inspectors/Utilities/SymbolicLinks/SymbolicLinkerWindow.cs @@ -5,7 +5,6 @@ using UnityEditor; using UnityEngine; using XRTK.Extensions; -using XRTK.Inspectors.Utilities.Packages; namespace XRTK.Inspectors.Utilities.SymbolicLinks { @@ -167,8 +166,6 @@ private void OnGUI() MixedRealityPreferences.AutoLoadSymbolicLinks = true; SymbolicLinker.AddLink(sourcePath, targetPath); - MixedRealityPackageUtilities.ValidatePackages(); - EditorUtility.SetDirty(SymbolicLinker.Settings); AssetDatabase.SaveAssets(); diff --git a/XRTK-Core/Packages/com.xrtk.core/XRTK.asmdef b/XRTK-Core/Packages/com.xrtk.core/XRTK.asmdef index 16b167949..6506ac92b 100644 --- a/XRTK-Core/Packages/com.xrtk.core/XRTK.asmdef +++ b/XRTK-Core/Packages/com.xrtk.core/XRTK.asmdef @@ -1,8 +1,7 @@ { "name": "XRTK", "references": [ - "XRTK.Utilities.Editor", - "Unity.ugui" + "XRTK.Utilities.Editor" ], "optionalUnityReferences": [], "includePlatforms": [], @@ -11,5 +10,6 @@ "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, - "defineConstraints": [] + "defineConstraints": [], + "versionDefines": [] } \ No newline at end of file diff --git a/XRTK-Core/Packages/com.xrtk.core/package.json b/XRTK-Core/Packages/com.xrtk.core/package.json index 7945a81a0..729fdee9b 100644 --- a/XRTK-Core/Packages/com.xrtk.core/package.json +++ b/XRTK-Core/Packages/com.xrtk.core/package.json @@ -2,13 +2,23 @@ "name": "com.xrtk.core", "displayName": "XRTK.Core", "description": "The core framework of the Mixed Reality Toolkit", - "version": "0.1.18", + "keywords": [ + "XRTK", + "VR", + "AR", + "XR", + "Mixed Reality", + "DI" + ], + "version": "0.1.19", "unity": "2019.1", "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/XRTK/XRTK-Core.git" - }, - "src": "Assets/XRTK", - "author": "XRTK Team (https://github.com/XRTK)" -} + "author": "XRTK Team (https://github.com/XRTK)", + "dependencies": { + "com.unity.ugui": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.textmeshpro": "1.0.0", + "com.unity.xr.legacyinputhelpers": "2.0.6" + } +} \ No newline at end of file diff --git a/XRTK-Core/Packages/manifest.json b/XRTK-Core/Packages/manifest.json index ad142e125..b342ccf26 100644 --- a/XRTK-Core/Packages/manifest.json +++ b/XRTK-Core/Packages/manifest.json @@ -1,4 +1,13 @@ { + "scopedRegistries": [ + { + "name": "XRTK", + "url": "http://35.224.131.252:4873/", + "scopes": [ + "com.xrtk" + ] + } + ], "dependencies": { "com.unity.package-manager-ui": "2.1.2", "com.unity.textmeshpro": "2.0.1",