43 lines
982 B
C#
43 lines
982 B
C#
using UnityEngine;
|
|
|
|
public class GuardianBoundaryDisplay : MonoBehaviour
|
|
{
|
|
public GuardianBoundaryEnforcer m_enforcer;
|
|
|
|
public OVRBoundary.BoundaryType m_boundaryType;
|
|
|
|
public GameObject m_errorDisplay;
|
|
|
|
private void Start()
|
|
{
|
|
m_enforcer.TrackingChanged += RefreshDisplay;
|
|
RefreshDisplay();
|
|
}
|
|
|
|
private void RefreshDisplay()
|
|
{
|
|
bool configured = OVRManager.boundary.GetConfigured();
|
|
if (configured)
|
|
{
|
|
LineRenderer component = GetComponent<LineRenderer>();
|
|
component.positionCount = 0;
|
|
Vector3[] geometry = OVRManager.boundary.GetGeometry(m_boundaryType);
|
|
component.positionCount = geometry.Length + 1;
|
|
Vector3 position;
|
|
for (int i = 0; i < geometry.Length; i++)
|
|
{
|
|
position = geometry[i];
|
|
position.y = 0f;
|
|
component.SetPosition(i, position);
|
|
}
|
|
position = geometry[0];
|
|
position.y = 0f;
|
|
component.SetPosition(geometry.Length, position);
|
|
}
|
|
if ((bool)m_errorDisplay)
|
|
{
|
|
m_errorDisplay.SetActive(!configured);
|
|
}
|
|
}
|
|
}
|