diff --git a/Submodules/Lumin b/Submodules/Lumin index 10c703fdd..b7d8ca0bf 160000 --- a/Submodules/Lumin +++ b/Submodules/Lumin @@ -1 +1 @@ -Subproject commit 10c703fdd2ec90545cde8e2ad991ac06b9865448 +Subproject commit b7d8ca0bfe383c824e2b0afa978131c636833d4a diff --git a/Submodules/Oculus b/Submodules/Oculus index 09e6e34b3..dee5435e4 160000 --- a/Submodules/Oculus +++ b/Submodules/Oculus @@ -1 +1 @@ -Subproject commit 09e6e34b38d82c135a3efdfc91a623af8f504395 +Subproject commit dee5435e418b7ef58c0bbd0c6a0ca3789306771e diff --git a/Submodules/SDK b/Submodules/SDK index dbfdcad47..6f0be2a7d 160000 --- a/Submodules/SDK +++ b/Submodules/SDK @@ -1 +1 @@ -Subproject commit dbfdcad47bbe091746709bb18f21eed72ded1554 +Subproject commit 6f0be2a7d72f2460768b671b4af971c75a3c1f26 diff --git a/Submodules/WindowsMixedReality b/Submodules/WindowsMixedReality index 29757285e..0422616fe 160000 --- a/Submodules/WindowsMixedReality +++ b/Submodules/WindowsMixedReality @@ -1 +1 @@ -Subproject commit 29757285ee02a4040f4fb2ab9a0b9f5db2466bda +Subproject commit 0422616fe946375eca2472a5aa6094139b4c6e73 diff --git a/Submodules/glTF b/Submodules/glTF index b0b4fffbf..c6e72c7c3 160000 --- a/Submodules/glTF +++ b/Submodules/glTF @@ -1 +1 @@ -Subproject commit b0b4fffbfbe79f37ccc9ab579cdcc3565b39b8d4 +Subproject commit c6e72c7c30818a2314601426907b1ba14bec2ca9 diff --git a/XRTK-Core/Packages/com.xrtk.core/Editor/AssemblyInfo.cs b/XRTK-Core/Packages/com.xrtk.core/Editor/AssemblyInfo.cs index cdea39e19..11c70967e 100644 --- a/XRTK-Core/Packages/com.xrtk.core/Editor/AssemblyInfo.cs +++ b/XRTK-Core/Packages/com.xrtk.core/Editor/AssemblyInfo.cs @@ -1,10 +1,11 @@ -// Copyright (c) XRTK. All rights reserved. +// Copyright (c) XRTK. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #define XRTK_EDITOR using System.Reflection; +[assembly: AssemblyVersion("0.2.15")] [assembly: AssemblyTitle("com.xrtk.core.editor")] [assembly: AssemblyCompany("XRTK")] [assembly: AssemblyCopyright("Copyright (c) XRTK. All rights reserved.")] diff --git a/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionEditorExtension.cs b/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionEditorExtension.cs index d96e681b0..b4ea16bc7 100644 --- a/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionEditorExtension.cs +++ b/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionEditorExtension.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) XRTK. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. using System; @@ -28,9 +28,10 @@ internal class AsmDefSourceFiles } [Serializable] - internal class CustomScriptAssemblyData + internal class AssemblyDefinition { public string name = null; + public string version = null; public string[] references = null; public string[] optionalUnityReferences = null; public string[] includePlatforms = null; @@ -39,9 +40,9 @@ internal class CustomScriptAssemblyData public AsmDefSourceFiles Source { get; set; } = new AsmDefSourceFiles(); - public static CustomScriptAssemblyData FromJson(string json) + public static AssemblyDefinition FromJson(string json) { - var scriptAssemblyData = JsonUtility.FromJson(json); + var scriptAssemblyData = JsonUtility.FromJson(json); if (scriptAssemblyData == null) { throw new Exception("Json file does not contain an assembly definition"); } if (string.IsNullOrEmpty(scriptAssemblyData.name)) { throw new Exception("Required property 'name' not set"); } if (scriptAssemblyData.excludePlatforms != null && scriptAssemblyData.excludePlatforms.Length > 0 && @@ -53,9 +54,9 @@ public static CustomScriptAssemblyData FromJson(string json) return scriptAssemblyData; } - public static string ToJson(CustomScriptAssemblyData data) + public static string ToJson(AssemblyDefinition definition) { - return JsonUtility.ToJson(data, true); + return JsonUtility.ToJson(definition, true); } } @@ -78,7 +79,7 @@ public static void ReplaceWithAssembly() var assetPath = AssetDatabase.GetAssetPath(Selection.activeObject); var directoryPath = new FileInfo(assetPath).Directory?.FullName; var assemblyDefinitionText = AssetDatabase.LoadAssetAtPath(assetPath).text; - var scriptAssemblyData = CustomScriptAssemblyData.FromJson(assemblyDefinitionText); + var scriptAssemblyData = AssemblyDefinition.FromJson(assemblyDefinitionText); var fromAssemblyName = CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyName(scriptAssemblyData.name); Debug.Assert(!string.IsNullOrEmpty(scriptAssemblyData.name)); @@ -88,7 +89,7 @@ public static void ReplaceWithAssembly() CompilationPipeline.GetAssemblies(AssembliesType.Player).ReplaceSourceWithAssembly(ref scriptAssemblyData, directoryPath)) { EditorUtility.DisplayProgressBar("Replacing source with assembly", "Saving source meta data for later...", 0.95f); - File.WriteAllText(assetPath, CustomScriptAssemblyData.ToJson(scriptAssemblyData)); + File.WriteAllText(assetPath, AssemblyDefinition.ToJson(scriptAssemblyData)); File.WriteAllText($"{Path.GetFullPath(assetPath).Hide()}{JSON}", JsonUtility.ToJson(scriptAssemblyData.Source, true)); } else @@ -104,7 +105,7 @@ public static void ReplaceWithAssembly() EditorUtility.ClearProgressBar(); } - private static bool ReplaceSourceWithAssembly(this Assembly[] assemblies, ref CustomScriptAssemblyData assemblyData, string directoryPath) + private static bool ReplaceSourceWithAssembly(this Assembly[] assemblies, ref AssemblyDefinition assemblyDefinition, string directoryPath) { EditorUtility.DisplayProgressBar("Replacing source with assembly", "Gathering assembly information...", 0.1f); @@ -113,13 +114,13 @@ private static bool ReplaceSourceWithAssembly(this Assembly[] assemblies, ref Cu Assembly assembly = assemblies[i]; EditorUtility.DisplayProgressBar("Replacing source with assembly", $"Processing assembly {assembly.name}", i / (float)assemblies.Length); - if (assembly.name != assemblyData.name) { continue; } + if (assembly.name != assemblyDefinition.name) { continue; } Debug.Assert(assembly.sourceFiles != null); Debug.Assert(assembly.sourceFiles.Length > 0); Debug.Assert(File.Exists(assembly.outputPath)); - assemblyData.Source.Files = assembly.sourceFiles; + assemblyDefinition.Source.Files = assembly.sourceFiles; AssetDatabase.ReleaseCachedFileHandles(); for (var j = 0; j < assembly.sourceFiles.Length; j++) @@ -153,8 +154,8 @@ private static bool ReplaceSourceWithAssembly(this Assembly[] assemblies, ref Cu return true; } - if (assemblyData.excludePlatforms != null && assemblyData.excludePlatforms.Length > 0 && - assemblyData.includePlatforms != null && assemblyData.includePlatforms.Length > 0) + if (assemblyDefinition.excludePlatforms != null && assemblyDefinition.excludePlatforms.Length > 0 && + assemblyDefinition.includePlatforms != null && assemblyDefinition.includePlatforms.Length > 0) { Selection.activeObject = importedAssembly; Debug.LogError("Unable to update plugin import settings, as both exclude and include platforms have been enabled."); @@ -162,28 +163,28 @@ private static bool ReplaceSourceWithAssembly(this Assembly[] assemblies, ref Cu } BuildTarget buildTarget; - importedAssembly.SetCompatibleWithAnyPlatform(assemblyData.includePlatforms == null || assemblyData.includePlatforms.Length == 0); + importedAssembly.SetCompatibleWithAnyPlatform(assemblyDefinition.includePlatforms == null || assemblyDefinition.includePlatforms.Length == 0); - if (assemblyData.includePlatforms != null && assemblyData.includePlatforms.Length > 0) + if (assemblyDefinition.includePlatforms != null && assemblyDefinition.includePlatforms.Length > 0) { - importedAssembly.SetCompatibleWithEditor(assemblyData.includePlatforms.Contains("Editor")); + importedAssembly.SetCompatibleWithEditor(assemblyDefinition.includePlatforms.Contains("Editor")); - for (int j = 0; j < assemblyData.includePlatforms?.Length; j++) + for (int j = 0; j < assemblyDefinition.includePlatforms?.Length; j++) { - if (assemblyData.includePlatforms[j].TryGetBuildTarget(out buildTarget)) + if (assemblyDefinition.includePlatforms[j].TryGetBuildTarget(out buildTarget)) { importedAssembly.SetCompatibleWithPlatform(buildTarget, true); } } } - if (assemblyData.excludePlatforms != null && assemblyData.excludePlatforms.Length > 0) + if (assemblyDefinition.excludePlatforms != null && assemblyDefinition.excludePlatforms.Length > 0) { - importedAssembly.SetCompatibleWithEditor(!assemblyData.excludePlatforms.Contains("Editor")); + importedAssembly.SetCompatibleWithEditor(!assemblyDefinition.excludePlatforms.Contains("Editor")); - for (int j = 0; j < assemblyData.excludePlatforms?.Length; j++) + for (int j = 0; j < assemblyDefinition.excludePlatforms?.Length; j++) { - if (assemblyData.excludePlatforms[j].TryGetBuildTarget(out buildTarget)) + if (assemblyDefinition.excludePlatforms[j].TryGetBuildTarget(out buildTarget)) { importedAssembly.SetExcludeFromAnyPlatform(buildTarget, true); } @@ -241,7 +242,7 @@ public static void ReplaceWithSource() var assemblyDefinitionAsset = AssetDatabase.LoadAssetAtPath(assemblyDefinitionPath); Debug.Assert(assemblyDefinitionAsset != null, $"Failed to load assembly def asset at {assemblyDefinitionPath}"); var assemblyDefinitionText = assemblyDefinitionAsset.text; - var scriptAssemblyData = CustomScriptAssemblyData.FromJson(assemblyDefinitionText); + var scriptAssemblyData = AssemblyDefinition.FromJson(assemblyDefinitionText); var assemblySourcePath = $"{Path.GetFullPath(assemblyDefinitionPath).Hide()}{JSON}"; Debug.Assert(File.Exists(assemblySourcePath), "Fatal Error: Missing meta data to re-import source files. You'll need to manually do it by removing the '.' in front of each file."); string sourceFilesText = File.ReadAllText(assemblySourcePath); diff --git a/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionPreProcessor.cs b/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionPreProcessor.cs new file mode 100644 index 000000000..d03d82072 --- /dev/null +++ b/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionPreProcessor.cs @@ -0,0 +1,39 @@ +// Copyright (c) XRTK. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.IO; +using System.Text.RegularExpressions; +using UnityEditor; +using UnityEngine; + +namespace XRTK.Editor.Utilities +{ + internal class AssemblyDefinitionPreProcessor : AssetPostprocessor + { + private const string VersionRegexPattern = "\\[assembly: AssemblyVersion\\(\"(.*)\"\\)\\]"; + + private void OnPreprocessAsset() + { + if (assetPath.Contains("package.json") && !Application.isBatchMode) + { + var text = File.ReadAllText(assetPath); + var asmdef = AssemblyDefinitionEditorExtension.AssemblyDefinition.FromJson(text); + + if (!asmdef.name.Contains("com.xrtk")) + { + return; + } + + var newVersion = $"[assembly: AssemblyVersion(\"{asmdef.version}\")]"; + var assemblyPath = assetPath.Replace("package.json", "Runtime/AssemblyInfo.cs"); + var editorAssemblyPath = assetPath.Replace("package.json", "Editor/AssemblyInfo.cs"); + + Debug.Assert(File.Exists(assemblyPath)); + Debug.Assert(File.Exists(editorAssemblyPath)); + + File.WriteAllText(assemblyPath, Regex.Replace(File.ReadAllText(assemblyPath), VersionRegexPattern, newVersion)); + File.WriteAllText(editorAssemblyPath, Regex.Replace(File.ReadAllText(editorAssemblyPath), VersionRegexPattern, newVersion)); + } + } + } +} diff --git a/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionPreProcessor.cs.meta b/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionPreProcessor.cs.meta new file mode 100644 index 000000000..fbaec1b86 --- /dev/null +++ b/XRTK-Core/Packages/com.xrtk.core/Editor/Utilities/AssemblyDefinitionPreProcessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae88737d43244bc3928db0d855c2d44a +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/Runtime/AssemblyInfo.cs b/XRTK-Core/Packages/com.xrtk.core/Runtime/AssemblyInfo.cs index 1336e68b6..4e135ed3b 100644 --- a/XRTK-Core/Packages/com.xrtk.core/Runtime/AssemblyInfo.cs +++ b/XRTK-Core/Packages/com.xrtk.core/Runtime/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) XRTK. All rights reserved. +// Copyright (c) XRTK. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #define XRTK @@ -6,6 +6,7 @@ using System.Reflection; using System.Runtime.CompilerServices; +[assembly: AssemblyVersion("0.2.15")] [assembly: AssemblyTitle("com.xrtk.core")] [assembly: AssemblyCompany("XRTK")] [assembly: AssemblyCopyright("Copyright (c) XRTK. All rights reserved.")] diff --git a/XRTK-Core/Packages/com.xrtk.core/Runtime/Services/MixedRealityToolkit.cs b/XRTK-Core/Packages/com.xrtk.core/Runtime/Services/MixedRealityToolkit.cs index f874f8789..89837e290 100644 --- a/XRTK-Core/Packages/com.xrtk.core/Runtime/Services/MixedRealityToolkit.cs +++ b/XRTK-Core/Packages/com.xrtk.core/Runtime/Services/MixedRealityToolkit.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading.Tasks; using UnityEngine; using UnityEngine.EventSystems; @@ -2005,5 +2006,25 @@ private void OnDispose(bool finalizing) } #endregion IDisposable Implementation + + private static List> modules = null; + + /// + /// The list of active xrtk modules/packages currently loaded into runtime. + /// + public static List> Modules + { + get + { + return modules ?? (modules = AppDomain.CurrentDomain.GetAssemblies() + .Where(assembly => + { + var titleAttribute = assembly.GetCustomAttribute(); + return titleAttribute != null && titleAttribute.Title.Contains("xrtk"); + }) + .Select(assembly => new Tuple(assembly.GetCustomAttribute().Title, assembly.GetName().Version)) + .ToList()); + } + } } }