Skip to content

Instantly share code, notes, and snippets.

@tarukosu
Created April 23, 2017 06:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarukosu/7bc78c189d8a7de8e94ca3fcfc8f7738 to your computer and use it in GitHub Desktop.
Save tarukosu/7bc78c189d8a7de8e94ca3fcfc8f7738 to your computer and use it in GitHub Desktop.
SpatialMappingNavMesh.cs
using HoloToolkit.Unity.SpatialMapping;
using UnityEngine;
using HoloToolkit.Unity;
public class SpatialMappingNavMesh : MonoBehaviour {
public GameObject SpatialMapping;
private void Awake () {
var spatialMappingSources = SpatialMapping.GetComponents<SpatialMappingSource>();
foreach (var source in spatialMappingSources)
{
source.SurfaceAdded += SpatialMappingSource_SurfaceAdded;
source.SurfaceUpdated += SpatialMappingSource_SurfaceUpdated;
}
}
void Start()
{
}
private void SpatialMappingSource_SurfaceAdded(object sender, DataEventArgs<SpatialMappingSource.SurfaceObject> e)
{
e.Data.Object.AddComponent<NavMeshSourceTag>();
}
private void SpatialMappingSource_SurfaceUpdated(object sender, DataEventArgs<SpatialMappingSource.SurfaceUpdate> e)
{
var navMeshSourceTag = e.Data.New.Object.GetComponent<NavMeshSourceTag>();
if(navMeshSourceTag == null)
{
e.Data.New.Object.AddComponent<NavMeshSourceTag>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment