Skip to content

Commit 78c3962

Browse files
authored
Merge pull request #2467 from keveleigh/SpatialMappingConfigure
Add "Add the Spatial Mapping Prefab" to the scene configuration window
2 parents 3490d1d + 23e2529 commit 78c3962

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

Assets/HoloToolkit/Utilities/Scripts/Editor/SceneSettingsWindow.cs

+38-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using HoloToolkit.Unity.InputModule;
5+
using HoloToolkit.Unity.SpatialMapping;
6+
using UnityEditor;
7+
using UnityEditor.SceneManagement;
48
using UnityEngine;
59
using UnityEngine.EventSystems;
610
using UnityEngine.SceneManagement;
7-
using UnityEditor;
8-
using UnityEditor.SceneManagement;
9-
using HoloToolkit.Unity.InputModule;
1011
using Cursor = HoloToolkit.Unity.InputModule.Cursor;
1112

1213
namespace HoloToolkit.Unity
@@ -23,17 +24,23 @@ public class SceneSettingsWindow : AutoConfigureWindow<SceneSettingsWindow.Scene
2324
private const string CameraPrefabGUID = "d29bc40b7f3df26479d6a0aac211c355";
2425

2526
/// <summary>
26-
/// Can be found in the meta file of the camera prefab. We use the GUID in case people move the toolkit folders &amp; assets around in their own projects.
27-
/// <remarks>Currently points to the InputManager.prefab</remarks>
27+
/// Can be found in the meta file of the input system prefab. We use the GUID in case people move the toolkit folders &amp; assets around in their own projects.
28+
/// <remarks>Currently points to InputManager.prefab</remarks>
2829
/// </summary>
2930
private const string InputSystemPrefabGUID = "3eddd1c29199313478dd3f912bfab2ab";
3031

3132
/// <summary>
32-
/// Can be found in the meta file of the camera prefab. We use the GUID in case people move the toolkit folders &amp; assets around in their own projects.
33-
/// <remarks>Currently points to the DefaultCursor.prefab</remarks>
33+
/// Can be found in the meta file of the default cursor prefab. We use the GUID in case people move the toolkit folders &amp; assets around in their own projects.
34+
/// <remarks>Currently points to DefaultCursor.prefab</remarks>
3435
/// </summary>
3536
private const string DefaultCursorPrefabGUID = "a611e772ef8ddf64d8106a9cbb70f31c";
3637

38+
/// <summary>
39+
/// Can be found in the meta file of the spatial mapping prefab. We use the GUID in case people move the toolkit folders &amp; assets around in their own projects.
40+
/// <remarks>Currently points to SpatialMapping.prefab</remarks>
41+
/// </summary>
42+
private const string SpatialMappingPrefabGUID = "2ed75ffdf9031c94e8bce4b3d17b9928";
43+
3744
#region Nested Types
3845

3946
public enum SceneSetting
@@ -42,7 +49,8 @@ public enum SceneSetting
4249
CameraToOrigin,
4350
AddInputSystem,
4451
AddDefaultCursor,
45-
UpdateCanvases
52+
UpdateCanvases,
53+
AddSpatialMapping
4654
}
4755

4856
#endregion // Nested Types
@@ -129,6 +137,19 @@ protected override void ApplySettings()
129137
FindObjectOfType<InputManager>().GetComponent<SimpleSinglePointerSelector>().Cursor = FindObjectOfType<Cursor>();
130138
}
131139

140+
if (Values[SceneSetting.AddSpatialMapping])
141+
{
142+
var spatialMappingManagers = FindObjectsOfType<SpatialMappingManager>();
143+
if (spatialMappingManagers.Length > 0)
144+
{
145+
Debug.LogWarning("There's already a SpatialMappingManager in the scene. Did not add the SpatialMapping prefab.");
146+
}
147+
else
148+
{
149+
PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(SpatialMappingPrefabGUID)));
150+
}
151+
}
152+
132153
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
133154

134155
Close();
@@ -140,6 +161,8 @@ protected override void LoadSettings()
140161
{
141162
Values[(SceneSetting)i] = true;
142163
}
164+
165+
Values[SceneSetting.AddSpatialMapping] = false;
143166
}
144167

145168
protected override void OnGuiChanged()
@@ -172,7 +195,7 @@ protected override void LoadStrings()
172195
Names[SceneSetting.AddDefaultCursor] = "Add the Default Cursor Prefab";
173196
Descriptions[SceneSetting.AddDefaultCursor] =
174197
"Recommended\n\n" +
175-
"Adds the Default Cursor Prefab to the scene.\n\n" +
198+
"Adds the Default Cursor Prefab to the scene.\n\n" +
176199
"The prefab comes preset with all the components and options for automatically handling cursor animations for Mixed Reality Applications.\n\n" +
177200
"<color=#ff0000ff><b>Warning!</b></color> This will remove and replace any currently existing Cursors in your scene.";
178201

@@ -182,6 +205,12 @@ protected override void LoadStrings()
182205
"Updates all the World Space Canvases in the scene to use the Focus Managers UIRaycastCamera as its default event camera.\n\n" +
183206
"<color=#ffff00ff><b>Note:</b></color> This also adds a CanvasHelper script to the canvas to aid in the scene transitions and instances where the camera does not " +
184207
"initially exist in the same scene as the canvas.";
208+
209+
Names[SceneSetting.AddSpatialMapping] = "Add the Spatial Mapping Prefab";
210+
Descriptions[SceneSetting.AddSpatialMapping] =
211+
"Adds the Spatial Mapping Prefab to the scene.\n\n" +
212+
"The prefab comes preset with the components and options for bringing spatial mapping into your HoloLens application.\n\n" +
213+
"<color=#ff0000ff><b>Warning!</b></color> This will remove and replace any currently existing Spatial Mapping Managers in your scene.";
185214
}
186215

187216
protected override void OnEnable()

0 commit comments

Comments
 (0)