diff --git a/UnityProjects/MRTKDevTemplate/Assets/MRTK.Generated/MRTK.Generated.sentinel b/UnityProjects/MRTKDevTemplate/Assets/MRTK.Generated/MRTK.Generated.sentinel new file mode 100644 index 000000000..e69de29bb diff --git a/UnityProjects/MRTKDevTemplate/Assets/MRTK.Generated/MRTK.Generated.sentinel.meta b/UnityProjects/MRTKDevTemplate/Assets/MRTK.Generated/MRTK.Generated.sentinel.meta new file mode 100644 index 000000000..174cbfd81 --- /dev/null +++ b/UnityProjects/MRTKDevTemplate/Assets/MRTK.Generated/MRTK.Generated.sentinel.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2402dd68deefc124ca12b591c71a7a05 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProjects/MRTKDevTemplate/Packages/packages-lock.json b/UnityProjects/MRTKDevTemplate/Packages/packages-lock.json index ce075f1d1..798300b97 100644 --- a/UnityProjects/MRTKDevTemplate/Packages/packages-lock.json +++ b/UnityProjects/MRTKDevTemplate/Packages/packages-lock.json @@ -400,7 +400,7 @@ "depth": 0, "source": "local", "dependencies": { - "org.mixedrealitytoolkit.core": "3.2.2" + "org.mixedrealitytoolkit.core": "3.3.0" } }, "org.mixedrealitytoolkit.uxcomponents": { diff --git a/org.mixedrealitytoolkit.core/CHANGELOG.md b/org.mixedrealitytoolkit.core/CHANGELOG.md index d9da38446..9ba3a8598 100644 --- a/org.mixedrealitytoolkit.core/CHANGELOG.md +++ b/org.mixedrealitytoolkit.core/CHANGELOG.md @@ -10,7 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added -* Added event `OnSpeechRecognitionKeywordChanged` to allow UI updates when the speech recognition keyword has changed. [PR #792](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/792/) +* Added event `OnSpeechRecognitionKeywordChanged` to allow UI updates when the speech recognition keyword has changed. [PR #792](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/792) +* Added support for moving the MRTK.Generated folder around the project's Assets folder structure instead of enforcing a root location. [PR #969](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/969) ### Fixed @@ -39,8 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). * Added IsProximityHovered property of type TimedFlag to detect when a button starts being hovered or on interactor proximity and when it stops being hovered or on proximity of any interactor. [PR #611](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/611) * Adding ProximityHover events (Entered & Exited) to PressableButton class. [PR #611](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/611) - ### Fixed * Fixed support for UPM package publishing in the Unity Asset Store. [PR #519](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/519) -* Fix warning and event triggered on disabled StatefulInteractable after changing speech settings [PR #591](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/591) [PR #608](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/608) \ No newline at end of file +* Fix warning and event triggered on disabled StatefulInteractable after changing speech settings [PR #591](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/591) [PR #608](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/608) diff --git a/org.mixedrealitytoolkit.core/Editor/MRTKBuildPreferences.cs b/org.mixedrealitytoolkit.core/Editor/MRTKBuildPreferences.cs index 52dfa7f22..106c75f9b 100644 --- a/org.mixedrealitytoolkit.core/Editor/MRTKBuildPreferences.cs +++ b/org.mixedrealitytoolkit.core/Editor/MRTKBuildPreferences.cs @@ -51,7 +51,7 @@ private static SettingsProvider BuildPreferences() static void GUIHandler(string searchContext) { - EditorGUILayout.HelpBox("These settings are serialized into MRTKSettings.asset in the MRTK.Generated folder.\nThis file can be checked into source control to maintain consistent settings across collaborators.", MessageType.Info); + EditorGUILayout.HelpBox($"These settings are serialized into MRTKSettings.asset in {MRTKFiles.GetOrCreateGeneratedFolderPath()}.\nThis file can be checked into source control to maintain consistent settings across collaborators.", MessageType.Info); DrawAppLauncherModelField(); } diff --git a/org.mixedrealitytoolkit.core/Editor/MRTKFiles.cs b/org.mixedrealitytoolkit.core/Editor/MRTKFiles.cs new file mode 100644 index 000000000..47f21a5d5 --- /dev/null +++ b/org.mixedrealitytoolkit.core/Editor/MRTKFiles.cs @@ -0,0 +1,93 @@ +// Copyright (c) Mixed Reality Toolkit Contributors +// Licensed under the BSD 3-Clause + +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace MixedReality.Toolkit.Editor +{ + /// + /// Provides helper methods for accessing MRTK-defined files and folders. + /// + public class MRTKFiles + { + private const string GeneratedName = "MRTK.Generated"; + private const string GeneratedSentinelFileName = GeneratedName + ".sentinel"; + + private static readonly string DefaultGeneratedFolderPath = Path.Combine("Assets", GeneratedName); + private static readonly string DefaultSentinelFilePath = Path.Combine(DefaultGeneratedFolderPath, GeneratedSentinelFileName); + private static string generatedFolderPath = string.Empty; + + /// + /// Finds the current MRTK.Generated folder based on the sentinel file. If a sentinel file is not found, + /// a new MRTK.Generated folder and sentinel are created and this new path is returned. + /// + /// The AssetDatabase-compatible path to the MRTK.Generated folder. + public static string GetOrCreateGeneratedFolderPath() + { + if (string.IsNullOrWhiteSpace(generatedFolderPath)) + { + foreach (string guid in AssetDatabase.FindAssets(GeneratedName)) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + if (path.Contains(GeneratedSentinelFileName)) + { + generatedFolderPath = Path.GetDirectoryName(path); + return generatedFolderPath; + } + } + + if (!Directory.Exists(DefaultGeneratedFolderPath)) + { + Directory.CreateDirectory(DefaultGeneratedFolderPath); + } + + if (!File.Exists(DefaultSentinelFilePath)) + { + // Make sure we create and dispose/close the filestream just created + using FileStream f = File.Create(DefaultSentinelFilePath); + } + generatedFolderPath = DefaultGeneratedFolderPath; + } + return generatedFolderPath; + } + + /// + /// Checks for an existing MRTK.Generated sentinel file on asset import. Allows the path to be pre-cached before use. + /// + private class AssetPostprocessor : UnityEditor.AssetPostprocessor + { + public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) + { + foreach (string asset in deletedAssets.Concat(movedFromAssetPaths)) + { + if (Path.GetFileName(asset) == GeneratedSentinelFileName && Path.GetDirectoryName(asset) == generatedFolderPath) + { + generatedFolderPath = string.Empty; + break; + } + } + + foreach (string asset in importedAssets.Concat(movedAssets)) + { + if (Path.GetFileName(asset) == GeneratedSentinelFileName) + { + string newPath = Path.GetDirectoryName(asset); + if (generatedFolderPath != newPath) + { + if (generatedFolderPath != string.Empty) + { + Debug.LogWarning($"Previous MRTK.Generated folder was not unregistered properly: {generatedFolderPath}.\nReplacing with {newPath}"); + } + Debug.Log($"Found MRTK.Generated sentinel at {newPath}."); + generatedFolderPath = newPath; + } + break; + } + } + } + } + } +} diff --git a/org.mixedrealitytoolkit.core/Editor/MRTKFiles.cs.meta b/org.mixedrealitytoolkit.core/Editor/MRTKFiles.cs.meta new file mode 100644 index 000000000..53ba7cceb --- /dev/null +++ b/org.mixedrealitytoolkit.core/Editor/MRTKFiles.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ec43400d20c14a248a30d6d4196d669e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/org.mixedrealitytoolkit.core/Editor/MRTKSettings.cs b/org.mixedrealitytoolkit.core/Editor/MRTKSettings.cs index f3e86bae2..64e3d85c0 100644 --- a/org.mixedrealitytoolkit.core/Editor/MRTKSettings.cs +++ b/org.mixedrealitytoolkit.core/Editor/MRTKSettings.cs @@ -14,8 +14,7 @@ namespace MixedReality.Toolkit.Editor [System.Serializable] public class MRTKSettings : ScriptableObject { - internal const string MRTKGeneratedFolder = "Assets/MRTK.Generated"; - internal const string MRTKSettingsPath = MRTKGeneratedFolder + "/MRTKSettings.asset"; + internal static string MRTKSettingsPath => Path.Combine(MRTKFiles.GetOrCreateGeneratedFolderPath(), "MRTKSettings.asset"); [SerializeField] private SerializableDictionary settings = new SerializableDictionary(); @@ -83,11 +82,6 @@ internal static MRTKSettings GetOrCreateSettings() var settings = AssetDatabase.LoadAssetAtPath(MRTKSettingsPath); if (settings == null) { - if (!Directory.Exists(MRTKGeneratedFolder)) - { - Directory.CreateDirectory(MRTKGeneratedFolder); - } - settings = CreateInstance(); AssetDatabase.CreateAsset(settings, MRTKSettingsPath); AssetDatabase.SaveAssets(); diff --git a/org.mixedrealitytoolkit.tools/CHANGELOG.md b/org.mixedrealitytoolkit.tools/CHANGELOG.md index 136ff5ea9..71939c84c 100644 --- a/org.mixedrealitytoolkit.tools/CHANGELOG.md +++ b/org.mixedrealitytoolkit.tools/CHANGELOG.md @@ -2,6 +2,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## Unreleased + +### Changed + +* Updated MRTK Core Definitions dependency to 3.3.0. [PR #969](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/969) + ## [3.0.5] - 2025-11-12 ### Fixed diff --git a/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemGenerator.cs b/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemGenerator.cs index e23be5962..ea9295bfb 100644 --- a/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemGenerator.cs +++ b/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemGenerator.cs @@ -2,6 +2,7 @@ // Licensed under the BSD 3-Clause using Microsoft.CSharp; +using MixedReality.Toolkit.Editor; using System; using System.Collections.Generic; using System.IO; @@ -33,7 +34,6 @@ internal class SubsystemGenerator private const bool DefaultCreateConfiguration = false; private static readonly string DefaultBaseSubsystemName = $"NewSubsystem"; - private static readonly string OutputFolderRoot = Path.Combine("Assets", "MRTK.Generated"); [SerializeField] private SubsystemWizardState state = SubsystemWizardState.Start; @@ -159,7 +159,7 @@ public void Generate( { // Make sure there is a folder in which to create the new files. DirectoryInfo outputFolder = new DirectoryInfo( - Path.Combine(OutputFolderRoot, SubsystemName)); + Path.Combine(MRTKFiles.GetOrCreateGeneratedFolderPath(), SubsystemName)); if (!outputFolder.Exists) { outputFolder.Create(); diff --git a/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemWizardWindow.cs b/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemWizardWindow.cs index e6724334b..c3b72de75 100644 --- a/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemWizardWindow.cs +++ b/org.mixedrealitytoolkit.tools/SubsystemWizard/SubsystemWizardWindow.cs @@ -247,7 +247,7 @@ private void RenderWizardPreGeneratePage() } EditorGUILayout.LabelField( - $"The new subsystem will be created in your project's MRTK.Generated/{subsystemGenerator.SubsystemName} folder.", + $"The new subsystem will be created in your project's {Path.Combine(MRTKFiles.GetOrCreateGeneratedFolderPath(), subsystemGenerator.SubsystemName)} folder.", EditorStyles.boldLabel); EditorGUILayout.Space(6); @@ -345,7 +345,7 @@ private void RenderWizardCompletePage() { StringBuilder sb = new StringBuilder(); int step = 1; - sb.AppendLine($" {step}. In the Project view, navigate to Assets/MRTK.Generated/{subsystemGenerator.SubsystemName}"); + sb.AppendLine($" {step}. In the Project view, navigate to {Path.Combine(MRTKFiles.GetOrCreateGeneratedFolderPath(), subsystemGenerator.SubsystemName)}"); step++; sb.AppendLine($" {step}. Open {subsystemGenerator.DescriptorName}.cs"); step++; diff --git a/org.mixedrealitytoolkit.tools/package.json b/org.mixedrealitytoolkit.tools/package.json index 9bcb37a38..6266be34f 100644 --- a/org.mixedrealitytoolkit.tools/package.json +++ b/org.mixedrealitytoolkit.tools/package.json @@ -17,6 +17,6 @@ "unityRelease": "26f1", "documentationUrl": "https://www.mixedrealitytoolkit.org", "dependencies": { - "org.mixedrealitytoolkit.core": "3.2.2" + "org.mixedrealitytoolkit.core": "3.3.0" } } \ No newline at end of file