/// <inheritdoc/> protected override List <Vector3> GetBoundaryGeometry() { // Boundaries are supported for Room Scale experiences only. if (XRDevice.GetTrackingSpaceType() != TrackingSpaceType.RoomScale) { return(null); } // Get the boundary geometry. var boundaryGeometry = new List <Vector3>(0); if (!UnityBoundary.TryGetGeometry(boundaryGeometry, UnityBoundary.Type.TrackedArea) || boundaryGeometry.Count == 0) { return(null); } return(boundaryGeometry); }
/// <summary> /// Retrieves the boundary geometry and creates the boundary and inscribed play space volumes. /// </summary> private void CalculateBoundaryBounds() { // Reset the bounds Bounds = new Edge[0]; FloorHeight = null; rectangularBounds = null; // Boundaries are supported for Room Scale experiences only. if (XRDevice.GetTrackingSpaceType() != TrackingSpaceType.RoomScale) { return; } // Get the boundary geometry. var boundaryGeometry = new List <Vector3>(0); var boundaryEdges = new List <Edge>(0); if (UnityBoundary.TryGetGeometry(boundaryGeometry, UnityBoundary.Type.TrackedArea) && boundaryGeometry.Count > 0) { // FloorHeight starts out as null. Use a suitably high value for the floor to ensure // that we do not accidentally set it too low. float floorHeight = float.MaxValue; for (int i = 0; i < boundaryGeometry.Count; i++) { Vector3 pointA = boundaryGeometry[i]; Vector3 pointB = boundaryGeometry[(i + 1) % boundaryGeometry.Count]; boundaryEdges.Add(new Edge(pointA, pointB)); floorHeight = Mathf.Min(floorHeight, boundaryGeometry[i].y); } FloorHeight = floorHeight; Bounds = boundaryEdges.ToArray(); CreateInscribedBounds(); } else { Debug.LogWarning("Failed to calculate boundary bounds."); } }