void Update() { // If no plane yet, disable the renderer and return. if (trackedPlane == null) { planeRenderer.EnablePlane(false); return; } // If this plane was subsumed by another plane, destroy this object, the other // plane's display will render it. if (trackedPlane.SubsumedBy != null) { Destroy(gameObject); return; } // If this plane is not valid or ARCore is not tracking, disable rendering. if (!trackedPlane.IsValid || Frame.TrackingState != FrameTrackingState.Tracking) { planeRenderer.EnablePlane(false); return; } // OK! Valid plane, so enable rendering and update the polygon data if needed. planeRenderer.EnablePlane(true); if (trackedPlane.IsUpdated) { trackedPlane.GetBoundaryPolygon(ref polygonVertices); planeRenderer.UpdateMeshWithCurrentTrackedPlane(trackedPlane.Position, polygonVertices); } }
// Update is called once per frame void Update() { // If no plane yet, disable the renderer and return. if (trackedPlane == null) { planeRenderer.EnablePlane(false); return; } // If this plane was subsumed by another plane, destroy this object, the other plane's display will render it. if (trackedPlane.SubsumedBy != null) { Destroy(gameObject); return; } // If this plane is not valid or ARCore is not tracking, disable rendering. if (trackedPlane.TrackingState != TrackingState.Tracking || Session.Status != SessionStatus.Tracking) { planeRenderer.EnablePlane(false); return; } // OK! Valid plane, so enable rendering and update the polygon data if needed. planeRenderer.EnablePlane(true); List <Vector3> newPolygonVertices = new List <Vector3>(); trackedPlane.GetBoundaryPolygon(newPolygonVertices); if (!AreVerticesListEqual(polygonVertices, newPolygonVertices)) { polygonVertices.Clear(); polygonVertices.AddRange(newPolygonVertices); planeRenderer.UpdateMeshWithCurrentTrackedPlane(trackedPlane.CenterPose.position, polygonVertices); } }