Skip to content

Commit 8578d80

Browse files
author
David Kline (ANALOG)
committed
add demo script to move the observer volume
1 parent ce8a51f commit 8578d80

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Assets/MixedRealityToolkit-Examples/Demos/SpatialAwareness/Scripts.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.MixedReality.Toolkit.Core.Interfaces.SpatialAwarenessSystem;
2+
using Microsoft.MixedReality.Toolkit.Core.Managers;
3+
using Microsoft.MixedReality.Toolkit.Core.Utilities;
4+
using UnityEngine;
5+
6+
namespace Microsoft.MixedReality.Toolkit.Examples.Demos.SpatialAwareness
7+
{
8+
/// <summary>
9+
/// Moves the spatial observer's origin to match the camera's position.
10+
/// </summary>
11+
public class SpatialObserverMover : MonoBehaviour
12+
{
13+
private IMixedRealitySpatialAwarenessSystem spatialAwarenessSystem = null;
14+
15+
/// <summary>
16+
/// The active <see cref="IMixedRealitySpatialAwarenessSystem"/> implementation.
17+
/// </summary>
18+
private IMixedRealitySpatialAwarenessSystem SpatialAwarenessSystem => spatialAwarenessSystem ?? (spatialAwarenessSystem = MixedRealityManager.SpatialAwarenessSystem);
19+
20+
void Update()
21+
{
22+
if (SpatialAwarenessSystem == null) { return; }
23+
24+
// Set the origin of the observer to the current camera position.
25+
SpatialAwarenessSystem.ObserverOrigin = CameraCache.Main.transform.position;
26+
}
27+
}
28+
}

Assets/MixedRealityToolkit-Examples/Demos/SpatialAwareness/Scripts/SpatialObserverMover.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)