Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Proper UPM registry support (#317)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
StephenHodgson authored Sep 13, 2019
1 parent 8636357 commit 9f47561
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 791 deletions.
3 changes: 0 additions & 3 deletions XRTK-Core/Assets/SymbolicLinkSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
79 changes: 26 additions & 53 deletions XRTK-Core/Assets/XRTK.Seed/MixedRealityPackageSeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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()
{
Expand All @@ -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");
}
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

/// <summary>
/// The path to the package settings found for this project.
/// </summary>
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.");
Expand Down Expand Up @@ -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<MixedRealityPackageSettings>(PackageSettingsPath);

if (shouldSync)
{
EditorApplication.delayCall += MixedRealityPackageUtilities.CheckPackageManifest;
}
}
else
{
PackageSettingsPath = string.Empty;
MixedRealityPackageUtilities.PackageSettings = null;
}
}

EditorGUIUtility.labelWidth = prevLabelWidth;
}

Expand Down

This file was deleted.

Loading

0 comments on commit 9f47561

Please sign in to comment.