From 01a39b620b855312d0d30d268b2d08c7946d7e94 Mon Sep 17 00:00:00 2001 From: chenyulin Date: Sun, 7 Apr 2024 01:46:06 +0800 Subject: [PATCH] feat. finish place menu --- Assets/Editor.meta | 8 + Assets/Editor/Migration.meta | 8 + .../Migration/AddVuforiaEnginePackage.cs | 478 ++++++++++++++++++ .../Migration/AddVuforiaEnginePackage.cs.meta | 11 + Assets/Scenes/SampleScene.unity | 185 ++++--- Assets/Script/UI/PlaceExplorer.cs | 72 +++ Assets/Script/UI/PlaceExplorer.cs.meta | 11 + Assets/XR/Loaders/ARCoreLoader.asset | 14 + Assets/XR/Loaders/ARCoreLoader.asset.meta | 8 + Assets/XR/Settings/ARCoreSettings.asset | 17 + Assets/XR/Settings/ARCoreSettings.asset.meta | 8 + .../XR/Settings/OpenXR Package Settings.asset | 2 +- ProjectSettings/ProjectSettings.asset | 3 + 13 files changed, 754 insertions(+), 71 deletions(-) create mode 100644 Assets/Editor.meta create mode 100644 Assets/Editor/Migration.meta create mode 100644 Assets/Editor/Migration/AddVuforiaEnginePackage.cs create mode 100644 Assets/Editor/Migration/AddVuforiaEnginePackage.cs.meta create mode 100644 Assets/Script/UI/PlaceExplorer.cs create mode 100644 Assets/Script/UI/PlaceExplorer.cs.meta create mode 100644 Assets/XR/Loaders/ARCoreLoader.asset create mode 100644 Assets/XR/Loaders/ARCoreLoader.asset.meta create mode 100644 Assets/XR/Settings/ARCoreSettings.asset create mode 100644 Assets/XR/Settings/ARCoreSettings.asset.meta diff --git a/Assets/Editor.meta b/Assets/Editor.meta new file mode 100644 index 0000000..7eb57b9 --- /dev/null +++ b/Assets/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 833e12f1d550f2c4b96eb6fa3a5ea199 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Migration.meta b/Assets/Editor/Migration.meta new file mode 100644 index 0000000..a7face0 --- /dev/null +++ b/Assets/Editor/Migration.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 784c1ed2aa16453488a41efb0eeae8ce +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Migration/AddVuforiaEnginePackage.cs b/Assets/Editor/Migration/AddVuforiaEnginePackage.cs new file mode 100644 index 0000000..84ba619 --- /dev/null +++ b/Assets/Editor/Migration/AddVuforiaEnginePackage.cs @@ -0,0 +1,478 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using UnityEditor; +using UnityEngine; + +[InitializeOnLoad] +public class AddVuforiaEnginePackage +{ + static readonly string sPackagesPath = Path.Combine(Application.dataPath, "..", "Packages"); + static readonly string sManifestJsonPath = Path.Combine(sPackagesPath, "manifest.json"); + const string VUFORIA_VERSION = "10.22.5"; + const string VUFORIA_TAR_FILE_DIR = "Assets/Editor/Migration/"; + const string DEPENDENCIES_DIR = "Assets/Resources/VuforiaDependencies"; + const string PACKAGES_RELATIVE_PATH = "Packages"; + const string MRTK_PACKAGE = "com.microsoft.mixedreality.toolkit.foundation"; + const string OPEN_XR_PACKAGE = "com.microsoft.mixedreality.openxr"; + + static readonly ScopedRegistry sVuforiaRegistry = new ScopedRegistry + { + name = "Vuforia", + url = "https://registry.packages.developer.vuforia.com/", + scopes = new[] { "com.ptc.vuforia" } + }; + + static AddVuforiaEnginePackage() + { + if (Application.isBatchMode) + return; + + var manifest = Manifest.JsonDeserialize(sManifestJsonPath); + + var packages = GetPackageDescriptions(); + + if (!packages.All(p => IsVuforiaUpToDate(manifest, p.BundleId))) + DisplayAddPackageDialog(manifest, packages); + + ResolveDependencies(manifest); + } + + public static void ResolveDependenciesSilent() + { + var manifest = Manifest.JsonDeserialize(sManifestJsonPath); + + var packages = GetDependencyDescriptions(); + if (packages != null && packages.Count > 0) + MoveDependencies(manifest, packages); + + CleanupDependenciesFolder(); + } + + static void ResolveDependencies(Manifest manifest) + { + var packages = GetDependencyDescriptions(); + if (packages != null && packages.Count > 0) + DisplayDependenciesDialog(manifest, packages); + } + + static bool IsVuforiaUpToDate(Manifest manifest, string bundleId) + { + var dependencies = manifest.Dependencies.Split(',').ToList(); + var upToDate = false; + + if(dependencies.Any(d => d.Contains(bundleId) && d.Contains("file:"))) + upToDate = IsUsingRightFileVersion(manifest, bundleId); + + return upToDate; + } + + static bool IsUsingRightFileVersion(Manifest manifest, string bundleId) + { + var dependencies = manifest.Dependencies.Split(',').ToList(); + return dependencies.Any(d => d.Contains(bundleId) && d.Contains("file:") && VersionNumberIsTheLatestTarball(d)); + } + + static bool VersionNumberIsTheLatestTarball(string package) + { + var version = package.Split('-'); + if (version.Length >= 2) + { + version[1] = version[1].TrimEnd(".tgz\"".ToCharArray()); + return IsCurrentVersionHigher(version[1]); + } + + return false; + } + + static bool IsCurrentVersionHigher(string currentVersionString) + { + if (string.IsNullOrEmpty(currentVersionString) || string.IsNullOrEmpty(VUFORIA_VERSION)) + return false; + + var currentVersion = TryConvertStringToVersion(currentVersionString); + var updatingVersion = TryConvertStringToVersion(VUFORIA_VERSION); + + if (currentVersion >= updatingVersion) + return true; + + return false; + } + + static Version TryConvertStringToVersion(string versionString) + { + Version res; + try + { + res = new Version(versionString); + } + catch (Exception) + { + return new Version(); + } + + return new Version(res.Major, res.Minor, res.Build); + } + + static void DisplayAddPackageDialog(Manifest manifest, IEnumerable packages) + { + if (EditorUtility.DisplayDialog("Add Vuforia Engine Package", + $"Would you like to update your project to include the Vuforia Engine {VUFORIA_VERSION} package from the unitypackage?\n" + + $"If an older Vuforia Engine package is already present in your project it will be upgraded to version {VUFORIA_VERSION}\n\n", + "Update", "Cancel")) + { + foreach (var package in packages) + { + MovePackageFile(VUFORIA_TAR_FILE_DIR, package.FileName); + UpdateManifest(manifest, package.BundleId, package.FileName); + } + } + } + + static void DisplayDependenciesDialog(Manifest manifest, IEnumerable packages) + { + if (EditorUtility.DisplayDialog("Add Sample Dependencies", + "Would you like to update your project to include all of its dependencies?\n" + + "If a different version of the package is already present, it will be deleted.\n\n", + "Update", "Cancel")) + { + MoveDependencies(manifest, packages); + CleanupDependenciesFolder(); + if (ShouldProjectRestart(packages)) + DisplayRestartDialog(); + } + } + + static void DisplayRestartDialog() + { + if (EditorUtility.DisplayDialog("Restart Unity Editor", + "Due to a Unity lifecycle issue, this project needs to be closed and re-opened " + + "after importing this Vuforia Engine sample.\n\n", + "Restart", "Cancel")) + { + RestartEditor(); + } + } + + static List GetPackageDescriptions() + { + var tarFilePaths = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), VUFORIA_TAR_FILE_DIR)).Where(f => f.EndsWith(".tgz")); + + // Define a regular expression for repeated words. + var rx = new Regex(@"(([a-z]+)(\.[a-z]+)*)\-((\d+)\.(\d+)\.(\d+))", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + var packageDescriptions = new List(); + + foreach (var filePath in tarFilePaths) + { + var fileName = Path.GetFileName(filePath); + // Find matches. + var matches = rx.Matches(fileName); + + // Report on each match. + foreach (Match match in matches) + { + var groups = match.Groups; + var bundleId = groups[1].Value; + var versionString = groups[4].Value; + + if (string.Equals(versionString, VUFORIA_VERSION)) + { + packageDescriptions.Add(new PackageDescription() + { + BundleId = bundleId, + FileName = fileName + }); + } + } + } + + return packageDescriptions; + } + + static List GetDependencyDescriptions() + { + var dependencyDirectory = Path.Combine(Directory.GetCurrentDirectory(), DEPENDENCIES_DIR); + if (!Directory.Exists(dependencyDirectory)) + return null; + var tarFilePaths = Directory.GetFiles(dependencyDirectory).Where(f => f.EndsWith(".tgz")); + + // Define a regular expression for repeated words. + var rx = new Regex(@"(([a-z]+)(\.[a-z]+)+)(\-((\d+)\.(\d+)\.(\d+)))*", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + var packageDescriptions = new List(); + + foreach (var filePath in tarFilePaths) + { + var fileName = Path.GetFileName(filePath); + // Find matches. + var matches = rx.Matches(fileName); + + // Report on each match. + foreach (Match match in matches) + { + var groups = match.Groups; + var bundleId = groups[1].Value; + bundleId = bundleId.Replace(".tgz", ""); + + packageDescriptions.Add(new PackageDescription + { + BundleId = bundleId, + FileName = fileName + }); + } + } + + return packageDescriptions; + } + + static void MoveDependencies(Manifest manifest, IEnumerable packages) + { + foreach (var package in packages) + { + RemoveDependency(manifest, package.BundleId, package.FileName); + MovePackageFile(DEPENDENCIES_DIR, package.FileName); + UpdateManifest(manifest, package.BundleId, package.FileName); + } + } + + static void MovePackageFile(string folder, string fileName) + { + var sourceFile = Path.Combine(Directory.GetCurrentDirectory(), folder, fileName); + var destFile = Path.Combine(Directory.GetCurrentDirectory(), PACKAGES_RELATIVE_PATH, fileName); + File.Copy(sourceFile, destFile, true); + File.Delete(sourceFile); + File.Delete(sourceFile + ".meta"); + } + + static void UpdateManifest(Manifest manifest, string bundleId, string fileName) + { + //remove existing, outdated NPM scoped registry if present + var registries = manifest.ScopedRegistries.ToList(); + if (registries.Contains(sVuforiaRegistry)) + { + registries.Remove(sVuforiaRegistry); + manifest.ScopedRegistries = registries.ToArray(); + } + + //add specified vuforia version via Git URL + SetVuforiaVersion(manifest, bundleId, fileName); + + manifest.JsonSerialize(sManifestJsonPath); + + AssetDatabase.Refresh(); + } + + static void RemoveDependency(Manifest manifest, string bundleId, string fileName) + { + var destFile = Path.Combine(Directory.GetCurrentDirectory(), PACKAGES_RELATIVE_PATH, fileName); + if (File.Exists(destFile)) + File.Delete(destFile); + + // remove existing + var dependencies = manifest.Dependencies.Split(',').ToList(); + for (var i = 0; i < dependencies.Count; i++) + { + if (dependencies[i].Contains(bundleId)) + { + dependencies.RemoveAt(i); + break; + } + } + + manifest.Dependencies = string.Join(",", dependencies); + + manifest.JsonSerialize(sManifestJsonPath); + + AssetDatabase.Refresh(); + } + + static void CleanupDependenciesFolder() + { + if (!Directory.Exists(DEPENDENCIES_DIR)) + return; + + Directory.Delete(DEPENDENCIES_DIR); + File.Delete(DEPENDENCIES_DIR + ".meta"); + AssetDatabase.Refresh(); + } + + static bool ShouldProjectRestart(IEnumerable packages) + { + return packages.Any(p => p.BundleId == MRTK_PACKAGE || p.BundleId == OPEN_XR_PACKAGE); + } + + static void RestartEditor() + { + EditorApplication.OpenProject(Directory.GetCurrentDirectory()); + } + + static void SetVuforiaVersion(Manifest manifest, string bundleId, string fileName) + { + var dependencies = manifest.Dependencies.Split(',').ToList(); + + var versionEntry = $"\"file:{fileName}\""; + var versionSet = false; + for (var i = 0; i < dependencies.Count; i++) + { + if (!dependencies[i].Contains(bundleId)) + continue; + + var kvp = dependencies[i].Split(':'); + dependencies[i] = kvp[0] + ": " + versionEntry; + versionSet = true; + } + + if (!versionSet) + dependencies.Insert(0, $"\n \"{bundleId}\": {versionEntry}"); + + manifest.Dependencies = string.Join(",", dependencies); + } + + class Manifest + { + const int INDEX_NOT_FOUND = -1; + const string DEPENDENCIES_KEY = "\"dependencies\""; + + public ScopedRegistry[] ScopedRegistries; + public string Dependencies; + + public void JsonSerialize(string path) + { + var jsonString = GetJsonString(); + + var startIndex = GetDependenciesStart(jsonString); + var endIndex = GetDependenciesEnd(jsonString, startIndex); + + var stringBuilder = new StringBuilder(); + + stringBuilder.Append(jsonString.Substring(0, startIndex)); + stringBuilder.Append(Dependencies); + stringBuilder.Append(jsonString.Substring(endIndex, jsonString.Length - endIndex)); + + File.WriteAllText(path, stringBuilder.ToString()); + } + + string GetJsonString() + { + if (ScopedRegistries.Length > 0) + return JsonUtility.ToJson( + new UnitySerializableManifest { scopedRegistries = ScopedRegistries, dependencies = new DependencyPlaceholder() }, + true); + + return JsonUtility.ToJson( + new UnitySerializableManifestDependenciesOnly() { dependencies = new DependencyPlaceholder() }, + true); + } + + + public static Manifest JsonDeserialize(string path) + { + var jsonString = File.ReadAllText(path); + + var registries = JsonUtility.FromJson(jsonString).scopedRegistries ?? new ScopedRegistry[0]; + var dependencies = DeserializeDependencies(jsonString); + + return new Manifest { ScopedRegistries = registries, Dependencies = dependencies }; + } + + static string DeserializeDependencies(string json) + { + var startIndex = GetDependenciesStart(json); + var endIndex = GetDependenciesEnd(json, startIndex); + + if (startIndex == INDEX_NOT_FOUND || endIndex == INDEX_NOT_FOUND) + return null; + + var dependencies = json.Substring(startIndex, endIndex - startIndex); + return dependencies; + } + + static int GetDependenciesStart(string json) + { + var dependenciesIndex = json.IndexOf(DEPENDENCIES_KEY, StringComparison.InvariantCulture); + if (dependenciesIndex == INDEX_NOT_FOUND) + return INDEX_NOT_FOUND; + + var dependenciesStartIndex = json.IndexOf('{', dependenciesIndex + DEPENDENCIES_KEY.Length); + + if (dependenciesStartIndex == INDEX_NOT_FOUND) + return INDEX_NOT_FOUND; + + dependenciesStartIndex++; //add length of '{' to starting point + + return dependenciesStartIndex; + } + + static int GetDependenciesEnd(string jsonString, int dependenciesStartIndex) + { + return jsonString.IndexOf('}', dependenciesStartIndex); + } + } + + class UnitySerializableManifestDependenciesOnly + { + public DependencyPlaceholder dependencies; + } + + class UnitySerializableManifest + { + public ScopedRegistry[] scopedRegistries; + public DependencyPlaceholder dependencies; + } + + [Serializable] + struct ScopedRegistry + { + public string name; + public string url; + public string[] scopes; + + public override bool Equals(object obj) + { + if (!(obj is ScopedRegistry)) + return false; + + var other = (ScopedRegistry)obj; + + return name == other.name && + url == other.url && + scopes.SequenceEqual(other.scopes); + } + + public static bool operator ==(ScopedRegistry a, ScopedRegistry b) + { + return a.Equals(b); + } + + public static bool operator !=(ScopedRegistry a, ScopedRegistry b) + { + return !a.Equals(b); + } + + public override int GetHashCode() + { + var hash = 17; + + foreach (var scope in scopes) + hash = hash * 23 + (scope == null ? 0 : scope.GetHashCode()); + + hash = hash * 23 + (name == null ? 0 : name.GetHashCode()); + hash = hash * 23 + (url == null ? 0 : url.GetHashCode()); + + return hash; + } + } + + [Serializable] + struct DependencyPlaceholder { } + + struct PackageDescription + { + public string BundleId; + public string FileName; + } +} \ No newline at end of file diff --git a/Assets/Editor/Migration/AddVuforiaEnginePackage.cs.meta b/Assets/Editor/Migration/AddVuforiaEnginePackage.cs.meta new file mode 100644 index 0000000..d617f0d --- /dev/null +++ b/Assets/Editor/Migration/AddVuforiaEnginePackage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3bbef22eb814a9647b6c1f03e99d95da +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 5d4b086..5b38659 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -1887,9 +1887,9 @@ MonoBehaviour: OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 0} - m_TargetAssemblyTypeName: - m_MethodName: Increment + - m_Target: {fileID: 1693172568} + m_TargetAssemblyTypeName: PlaceExplorer, Assembly-CSharp + m_MethodName: DeployObject m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -2587,9 +2587,9 @@ MonoBehaviour: OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 195322728} - m_TargetAssemblyTypeName: ToggleRoomMesh, Assembly-CSharp - m_MethodName: OnButtonPress + - m_Target: {fileID: 1693172568} + m_TargetAssemblyTypeName: PlaceExplorer, Assembly-CSharp + m_MethodName: ClearObject m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -4359,33 +4359,36 @@ MonoBehaviour: states: {fileID: 11400000, guid: e51893c8eb7938e4ba43985af43c0f72, type: 2} InputActionId: 0 isGlobal: 0 - Dimensions: 1 + Dimensions: 2 dimensionIndex: 0 startDimensionIndex: 0 - CanSelect: 0 - CanDeselect: 0 + CanSelect: 1 + CanDeselect: 1 voiceCommand: Select voiceRequiresFocus: 1 profiles: - Target: {fileID: 0} Themes: - {fileID: 11400000, guid: 0c4c73f326f602744bdcfff481fd6f20, type: 2} + - {fileID: 11400000, guid: 0c4c73f326f602744bdcfff481fd6f20, type: 2} - Target: {fileID: 993964064} Themes: - {fileID: 11400000, guid: 8f8cfb3041153fa45bccb6d664a563ec, type: 2} + - {fileID: 11400000, guid: 8f8cfb3041153fa45bccb6d664a563ec, type: 2} - Target: {fileID: 956773931} Themes: - {fileID: 11400000, guid: 087b16002c2b0b445baa3ed3beae44a9, type: 2} + - {fileID: 11400000, guid: 087b16002c2b0b445baa3ed3beae44a9, type: 2} OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 0} - m_TargetAssemblyTypeName: - m_MethodName: Increment - m_Mode: 1 + - m_Target: {fileID: 1693172568} + m_TargetAssemblyTypeName: PlaceExplorer, Assembly-CSharp + m_MethodName: ButtonPressed + m_Mode: 2 m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_ObjectArgument: {fileID: 317896245} + m_ObjectArgumentAssemblyTypeName: UnityEngine.GameObject, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -5976,8 +5979,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 415750604} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0.008} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.000000011175871, y: 0.000000007450581, z: 0.007999986} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -6184,33 +6187,36 @@ MonoBehaviour: states: {fileID: 11400000, guid: e51893c8eb7938e4ba43985af43c0f72, type: 2} InputActionId: 0 isGlobal: 0 - Dimensions: 1 + Dimensions: 2 dimensionIndex: 0 startDimensionIndex: 0 - CanSelect: 0 - CanDeselect: 0 + CanSelect: 1 + CanDeselect: 1 voiceCommand: Select voiceRequiresFocus: 1 profiles: - Target: {fileID: 0} Themes: - {fileID: 11400000, guid: 0c4c73f326f602744bdcfff481fd6f20, type: 2} + - {fileID: 11400000, guid: 0c4c73f326f602744bdcfff481fd6f20, type: 2} - Target: {fileID: 1518746321} Themes: - {fileID: 11400000, guid: 8f8cfb3041153fa45bccb6d664a563ec, type: 2} + - {fileID: 11400000, guid: 8f8cfb3041153fa45bccb6d664a563ec, type: 2} - Target: {fileID: 1149321069} Themes: - {fileID: 11400000, guid: 087b16002c2b0b445baa3ed3beae44a9, type: 2} + - {fileID: 11400000, guid: 087b16002c2b0b445baa3ed3beae44a9, type: 2} OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 0} - m_TargetAssemblyTypeName: - m_MethodName: Increment - m_Mode: 1 + - m_Target: {fileID: 1693172568} + m_TargetAssemblyTypeName: PlaceExplorer, Assembly-CSharp + m_MethodName: ButtonPressed + m_Mode: 2 m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_ObjectArgument: {fileID: 426005480} + m_ObjectArgumentAssemblyTypeName: UnityEngine.GameObject, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -7134,9 +7140,9 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 507539218} - m_LocalRotation: {x: -0.70710653, y: 0, z: 0, w: -0.70710707} + m_LocalRotation: {x: -0.7071065, y: -0, z: -0, w: -0.707107} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.01, y: 0.01, z: 0.01} + m_LocalScale: {x: 0.01, y: 0.010000002, z: 0.010000002} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 608917756} @@ -8503,6 +8509,7 @@ Transform: m_Children: - {fileID: 963194228} - {fileID: 1648845060} + - {fileID: 1718244464} m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -8530,7 +8537,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 608917755} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: -0.000000011175871, y: 0.000000022351742, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -8565,8 +8572,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 610881820} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0.008} - m_LocalScale: {x: 0.032, y: 0.032, z: 0.016} + m_LocalPosition: {x: -0.000000011175871, y: 0.000000022351742, z: -0.007999993} + m_LocalScale: {x: 0.032, y: 0.032000005, z: 0.016000004} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 43604459} @@ -11736,33 +11743,36 @@ MonoBehaviour: states: {fileID: 11400000, guid: e51893c8eb7938e4ba43985af43c0f72, type: 2} InputActionId: 0 isGlobal: 0 - Dimensions: 1 + Dimensions: 2 dimensionIndex: 0 startDimensionIndex: 0 - CanSelect: 0 - CanDeselect: 0 + CanSelect: 1 + CanDeselect: 1 voiceCommand: Select voiceRequiresFocus: 1 profiles: - Target: {fileID: 0} Themes: - {fileID: 11400000, guid: 0c4c73f326f602744bdcfff481fd6f20, type: 2} + - {fileID: 11400000, guid: 0c4c73f326f602744bdcfff481fd6f20, type: 2} - Target: {fileID: 610881820} Themes: - {fileID: 11400000, guid: 8f8cfb3041153fa45bccb6d664a563ec, type: 2} + - {fileID: 11400000, guid: 8f8cfb3041153fa45bccb6d664a563ec, type: 2} - Target: {fileID: 1047588675} Themes: - {fileID: 11400000, guid: 087b16002c2b0b445baa3ed3beae44a9, type: 2} + - {fileID: 11400000, guid: 087b16002c2b0b445baa3ed3beae44a9, type: 2} OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 0} - m_TargetAssemblyTypeName: - m_MethodName: Increment - m_Mode: 1 + - m_Target: {fileID: 1693172568} + m_TargetAssemblyTypeName: PlaceExplorer, Assembly-CSharp + m_MethodName: ButtonPressed + m_Mode: 2 m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_ObjectArgument: {fileID: 807787928} + m_ObjectArgumentAssemblyTypeName: UnityEngine.GameObject, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -12083,8 +12093,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 824242186} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.000000011175871, y: 0.000000022351742, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -13153,7 +13163,7 @@ Camera: m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 2 - m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 @@ -14830,7 +14840,7 @@ MonoBehaviour: - Name: Button2 Offset: {x: 0, y: 0} Radius: 0 - Transform: {fileID: 807787929} + Transform: {fileID: 0} Colliders: [] - Name: Button3 Offset: {x: 0, y: 0} @@ -15505,7 +15515,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1321460032} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.02, y: 0, z: -0.01} + m_LocalPosition: {x: -0.019999994, y: 0.0000000143051135, z: -0.010000011} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -15711,9 +15721,9 @@ MonoBehaviour: OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1321460034} - m_TargetAssemblyTypeName: ToggleRoomMesh, Assembly-CSharp - m_MethodName: OnButtonPress + - m_Target: {fileID: 1693172568} + m_TargetAssemblyTypeName: PlaceExplorer, Assembly-CSharp + m_MethodName: ToggleActive m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -15739,14 +15749,14 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 - ClassName: InteractableOnFocusReceiver - AssemblyQualifiedName: Microsoft.MixedReality.Toolkit.UI.InteractableOnFocusReceiver, - Microsoft.MixedReality.Toolkit.SDK + ClassName: InteractableAudioReceiver + AssemblyQualifiedName: Microsoft.MixedReality.Toolkit.UI.InteractableAudioReceiver, + Microsoft.MixedReality.Toolkit.SDK, Version=2.8.3.0, Culture=neutral, PublicKeyToken=null Settings: - - Type: 18 - Label: On Focus Off - Name: OnFocusOff - Tooltip: Focus has left the object + - Type: 17 + Label: Audio Clip + Name: AudioClip + Tooltip: Assign an audioclip to play on click IntValue: 0 StringValue: FloatValue: 0 @@ -15770,19 +15780,7 @@ MonoBehaviour: QuaternionValue: {x: 0, y: 0, z: 0, w: 0} EventValue: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 1321460040} - m_TargetAssemblyTypeName: - m_MethodName: AnimateOutHighlightPlate - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 + m_Calls: [] Options: [] - Event: m_PersistentCalls: @@ -18218,6 +18216,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1693172567} + - component: {fileID: 1693172568} m_Layer: 0 m_Name: Explorer m_TagString: Untagged @@ -18232,8 +18231,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1693172566} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.0177, y: 0.0823, z: -0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.017699968, y: 0.08230002, z: -0.000000003576279} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -18242,6 +18241,21 @@ Transform: m_Father: {fileID: 936113383} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1693172568 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1693172566} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 70a17284bc2a16247aed038c9082ec99, type: 3} + m_Name: + m_EditorClassIdentifier: + active: 0 + SelectedButton: {fileID: 0} + field: {fileID: 1718244464} --- !u!1 &1695316393 GameObject: m_ObjectHideFlags: 0 @@ -18422,6 +18436,37 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1700368087} m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1718244463 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1718244464} + m_Layer: 0 + m_Name: PlaceField + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1718244464 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1718244463} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 600980682} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1720124316 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Script/UI/PlaceExplorer.cs b/Assets/Script/UI/PlaceExplorer.cs new file mode 100644 index 0000000..bd3c13c --- /dev/null +++ b/Assets/Script/UI/PlaceExplorer.cs @@ -0,0 +1,72 @@ +using Microsoft.MixedReality.Toolkit.UI; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlaceExplorer : MonoBehaviour +{ + public bool active = false; + + public GameObject SelectedButton = null; + + public Transform field; + + public void ButtonPressed(GameObject button) + { + CancelButton(); + SelectedButton = button; + } + + public void CancelButton() + { + if (SelectedButton) + { + //SelectedButton.GetComponent().ButtonPressed.Invoke(); + } + } + + public void ClearObject() + { + for (int i = 0; i < field.childCount; i++) + { + Destroy(field.transform.GetChild(i).gameObject); + } + } + + public void DeployObject() + { + if (SelectedButton) + { + GameObject obj = Instantiate(SelectedButton.transform.Find("ButtonContent").GetChild(0).gameObject); + obj.SetActive(true); + obj.transform.parent = field; + obj.AddComponent(); + obj.transform.localScale = Vector3.one * 0.2f; + obj.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 0.4f; + } + } + + public void ToggleActive() + { + active = !active; + foreach (Transform item in transform) + { + item.gameObject.SetActive(active); + } + } + + // Start is called before the first frame update + void Start() + { + foreach (Transform item in transform) + { + item.gameObject.SetActive(active); + } + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Script/UI/PlaceExplorer.cs.meta b/Assets/Script/UI/PlaceExplorer.cs.meta new file mode 100644 index 0000000..fd3f9d0 --- /dev/null +++ b/Assets/Script/UI/PlaceExplorer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 70a17284bc2a16247aed038c9082ec99 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/XR/Loaders/ARCoreLoader.asset b/Assets/XR/Loaders/ARCoreLoader.asset new file mode 100644 index 0000000..f301129 --- /dev/null +++ b/Assets/XR/Loaders/ARCoreLoader.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 06042c85f885b4d1886f3ca5a1074eca, type: 3} + m_Name: ARCoreLoader + m_EditorClassIdentifier: diff --git a/Assets/XR/Loaders/ARCoreLoader.asset.meta b/Assets/XR/Loaders/ARCoreLoader.asset.meta new file mode 100644 index 0000000..cfa5821 --- /dev/null +++ b/Assets/XR/Loaders/ARCoreLoader.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dad62e5a543db04429ea19abd3fca082 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/XR/Settings/ARCoreSettings.asset b/Assets/XR/Settings/ARCoreSettings.asset new file mode 100644 index 0000000..3964eac --- /dev/null +++ b/Assets/XR/Settings/ARCoreSettings.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9dae4501572e1418791be3e3bf1f7faa, type: 3} + m_Name: ARCoreSettings + m_EditorClassIdentifier: + m_Requirement: 0 + m_Depth: 0 + m_IgnoreGradleVersion: 0 diff --git a/Assets/XR/Settings/ARCoreSettings.asset.meta b/Assets/XR/Settings/ARCoreSettings.asset.meta new file mode 100644 index 0000000..04a49e6 --- /dev/null +++ b/Assets/XR/Settings/ARCoreSettings.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4bc463e872eae924f83e660e13fcbce0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/XR/Settings/OpenXR Package Settings.asset b/Assets/XR/Settings/OpenXR Package Settings.asset index e3aa23a..e92d089 100644 --- a/Assets/XR/Settings/OpenXR Package Settings.asset +++ b/Assets/XR/Settings/OpenXR Package Settings.asset @@ -522,7 +522,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9f34c86d1a130cc45a438373e1e8a4fc, type: 3} m_Name: PlayModeRemotingPlugin Standalone m_EditorClassIdentifier: - m_enabled: 0 + m_enabled: 1 nameUi: Holographic Remoting for Play Mode version: 1.8.1 featureIdInternal: com.microsoft.openxr.feature.playmoderemoting diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 238f09c..5bd9db0 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -607,6 +607,9 @@ PlayerSettings: 1: USE_INPUT_SYSTEM_POSE_CONTROL;USE_INPUT_SYSTEM_POSE_CONTROL 14: USE_INPUT_SYSTEM_POSE_CONTROL;USE_INPUT_SYSTEM_POSE_CONTROL 7: USE_INPUT_SYSTEM_POSE_CONTROL;USE_INPUT_SYSTEM_POSE_CONTROL + Android: USE_INPUT_SYSTEM_POSE_CONTROL;USE_STICK_CONTROL_THUMBSTICKS + Standalone: USE_INPUT_SYSTEM_POSE_CONTROL;USE_STICK_CONTROL_THUMBSTICKS + Windows Store Apps: USE_INPUT_SYSTEM_POSE_CONTROL;USE_STICK_CONTROL_THUMBSTICKS additionalCompilerArguments: {} platformArchitecture: {} scriptingBackend: {}