Skip to content

Instantly share code, notes, and snippets.

@CameronVetter
Last active January 25, 2017 22:26
Show Gist options
  • Save CameronVetter/1fd7ecd1370f59373d0eff3baaa965e8 to your computer and use it in GitHub Desktop.
Save CameronVetter/1fd7ecd1370f59373d0eff3baaa965e8 to your computer and use it in GitHub Desktop.
SpatialUnderstandingState - Part 2
using System;
using UnityEngine;
using HoloToolkit.Unity;
using HoloToolkit.Unity.SpatialMapping;
public class SpatialUnderstandingState : Singleton<SpatialUnderstandingState>
{
public TextMesh DebugDisplay;
public TextMesh DebugSubDisplay;
private bool _triggered;
public bool HideText = false;
private string _spaceQueryDescription;
public string SpaceQueryDescription
{
get
{
return _spaceQueryDescription;
}
set
{
_spaceQueryDescription = value;
}
}
public string PrimaryText
{
get
{
if (HideText)
return string.Empty;
// Display the space and object query results (has priority)
if (!string.IsNullOrEmpty(SpaceQueryDescription))
{
return SpaceQueryDescription;
}
// Scan state
if (SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
{
switch (SpatialUnderstanding.Instance.ScanState)
{
case SpatialUnderstanding.ScanStates.Scanning:
// Get the scan stats
IntPtr statsPtr = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticPlayspaceStatsPtr();
if (SpatialUnderstandingDll.Imports.QueryPlayspaceStats(statsPtr) == 0)
{
return "playspace stats query failed";
}
return "Walk around and scan in your playspace";
case SpatialUnderstanding.ScanStates.Finishing:
return "Finalizing scan (please wait)";
case SpatialUnderstanding.ScanStates.Done:
return "Scan complete";
default:
return "ScanState = " + SpatialUnderstanding.Instance.ScanState;
}
}
return string.Empty;
}
}
public Color PrimaryColor
{
get
{
return Color.white;
}
}
public string DetailsText
{
get
{
return "DetailsText";
}
}
private void Update_DebugDisplay()
{
// Basic checks
if (DebugDisplay == null)
{
return;
}
// Update display text
DebugDisplay.text = PrimaryText;
DebugDisplay.color = PrimaryColor;
DebugSubDisplay.text = DetailsText;
}
// Update is called once per frame
private void Update()
{
// Updates
Update_DebugDisplay();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment