Skip to content

Commit

Permalink
Merge pull request #2 from Chen-Yulin/hideMesh
Browse files Browse the repository at this point in the history
Hide mesh
  • Loading branch information
Chen-Yulin authored Apr 2, 2024
2 parents 94e01dd + 6bd8079 commit 16564eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ MonoBehaviour:
spatialAwarenessSystemType:
reference: Microsoft.MixedReality.Toolkit.SpatialAwareness.MixedRealitySpatialAwarenessSystem,
Microsoft.MixedReality.Toolkit.Services.SpatialAwarenessSystem
spatialAwarenessSystemProfile: {fileID: 11400000, guid: 97da727944a3d7b4caf42d2273271a24, type: 2}
spatialAwarenessSystemProfile: {fileID: 11400000, guid: bacc3ee1fe0019e488dcc47839b347a6, type: 2}
diagnosticsSystemProfile: {fileID: 11400000, guid: 478436bd1083882479a52d067e98e537, type: 2}
enableDiagnosticsSystem: 0
diagnosticsSystemType:
Expand Down
17 changes: 7 additions & 10 deletions Assets/Script/UI/ToggleRoomMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,38 @@

public class ToggleRoomMesh : MonoBehaviour
{
public IMixedRealitySpatialAwarenessSystem spatialAwarenessSystem;
public IMixedRealitySpatialAwarenessMeshObserver observer;
public bool spatialMeshEnabled = false;

void Start()
{
// 获取Spatial Awareness系统
spatialAwarenessSystem = CoreServices.SpatialAwarenessSystem;
observer = CoreServices.GetSpatialAwarenessSystemDataProvider<IMixedRealitySpatialAwarenessMeshObserver>();

if (spatialAwarenessSystem == null)
if (observer == null)
{
Debug.LogError("Spatial Awareness System is not available.");
}
else
{
spatialAwarenessSystem.SuspendObservers();
observer.DisplayOption = SpatialAwarenessMeshDisplayOptions.Occlusion;
spatialMeshEnabled = false;
}
}

// 当按钮被按下时调用
public void OnButtonPress()
{
if (spatialAwarenessSystem != null)
if (observer != null)
{
if (spatialMeshEnabled)
{
// 关闭环境网格的显示
spatialAwarenessSystem.ClearObservations();
spatialAwarenessSystem.SuspendObservers();
observer.DisplayOption = SpatialAwarenessMeshDisplayOptions.Occlusion;
spatialMeshEnabled = false;
}
else
{
// 启用环境网格的显示
spatialAwarenessSystem.ResumeObservers();
observer.DisplayOption = SpatialAwarenessMeshDisplayOptions.Visible;
spatialMeshEnabled = true;
}
}
Expand Down

0 comments on commit 16564eb

Please sign in to comment.