SurfaceObserver is the main API portal for spatial mapping functionality in Unity.

Inheritance: IDisposable
        public bool RequestMeshAsync(SurfaceData dataRequest, SurfaceObserver.SurfaceDataReadyDelegate onDataReady)
        {
            if (onDataReady == null)
            {
                throw new ArgumentNullException("onDataReady");
            }
            if (dataRequest.outputMesh == null)
            {
                throw new ArgumentNullException("dataRequest.outputMesh");
            }
            if (dataRequest.outputAnchor == null)
            {
                throw new ArgumentNullException("dataRequest.outputAnchor");
            }
            if (dataRequest.outputCollider == null && dataRequest.bakeCollider)
            {
                throw new ArgumentException("dataRequest.outputCollider must be non-NULL if dataRequest.bakeCollider is true", "dataRequest.outputCollider");
            }
            if ((double)dataRequest.trianglesPerCubicMeter < 0.0)
            {
                throw new ArgumentException("dataRequest.trianglesPerCubicMeter must be greater than zero", "dataRequest.trianglesPerCubicMeter");
            }
            bool flag = SurfaceObserver.Internal_AddToWorkQueue(this.m_Observer, onDataReady, dataRequest.id.handle, dataRequest.outputMesh, dataRequest.outputAnchor, dataRequest.outputCollider, dataRequest.trianglesPerCubicMeter, dataRequest.bakeCollider);

            if (!flag)
            {
                Debug.LogError("RequestMeshAsync has failed.  Is your surface ID valid?");
            }
            return(flag);
        }
        private IntPtr Internal_Create()
        {
            IntPtr result;

            SurfaceObserver.INTERNAL_CALL_Internal_Create(this, out result);
            return(result);
        }
 public void Update(SurfaceObserver.SurfaceChangedDelegate onSurfaceChanged)
 {
     if (onSurfaceChanged == null)
     {
         throw new ArgumentNullException("onSurfaceChanged");
     }
     SurfaceObserver.Internal_Update(this.m_Observer, onSurfaceChanged);
 }
 public void Dispose()
 {
     if (this.m_Observer != IntPtr.Zero)
     {
         SurfaceObserver.Destroy(this.m_Observer);
         this.m_Observer = IntPtr.Zero;
     }
     GC.SuppressFinalize(this);
 }
 private static extern void INTERNAL_CALL_Internal_SetVolumeAsAxisAlignedBox(SurfaceObserver self, IntPtr observer, ref Vector3 origin, ref Vector3 extents);
 /// <summary>
 /// Standard initialization method creating our properties
 /// </summary>
 protected virtual void Start()
 {
     surfaceObserver = new SurfaceObserver();
     UpdateSurfaceObserverPosition();
     StartCoroutine(UpdateLoop());
     bounds = new Bounds(transform.position, Extents);
 }
 private static extern void INTERNAL_CALL_Internal_Create(SurfaceObserver self, out IntPtr value);
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (observer == null)
            {
                observer = new SurfaceObserver();
                observer.SetVolumeAsAxisAlignedBox(Vector3.zero, Extents);
            }

            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }
        }
        /// <summary>
        /// Cleans up all memory and objects associated with the observer.
        /// </summary>
        public void CleanupObserver()
        {
            if (observer != null)
            {
                StopObserving();

                // Clear out all memory allocated the observer
                observer.Dispose();
                observer = null;

                foreach (KeyValuePair<int, GameObject> surfaceRef in surfaces)
                {
                    CleanupSurface(surfaceRef.Value);
                }

                // Get all valid mesh filters for observed surfaces and destroy them
                List<MeshFilter> meshFilters = GetMeshFilters();
                for (int i = 0; i < meshFilters.Count; i++)
                {
                    Destroy(meshFilters[i].sharedMesh);
                }
                meshFilters.Clear();

                // Cleanup all available surfaces
                foreach (GameObject availableSurface in availableSurfaces)
                {
                    Destroy(availableSurface);
                }
                availableSurfaces.Clear();
                surfaces.Clear();
            }
        }
 private void Internal_SetVolumeAsOrientedBox(IntPtr observer, Vector3 origin, Vector3 extents, Quaternion orientation)
 {
     SurfaceObserver.INTERNAL_CALL_Internal_SetVolumeAsOrientedBox(this, observer, ref origin, ref extents, ref orientation);
 }
 private void Internal_SetVolumeAsSphere(IntPtr observer, Vector3 origin, float radiusMeters)
 {
     SurfaceObserver.INTERNAL_CALL_Internal_SetVolumeAsSphere(this, observer, ref origin, radiusMeters);
 }
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (ObserverState != ObserverStates.Running)
            {
                Debug.Log("Starting the observer.");
                // on device, this isn't necessary, but sometimes in the emulator the observer 
                // won't realize that it hasn't already sent you the surfaces, and since the surfaces
                // don't really get updated in the emulator you'll end up getting no surfaces at all.
                if (surfaces.Count == 0)
                {
                    if (observer != null)
                    {
                        observer.Dispose();
                        observer = null;
                    }

                    observer = new SurfaceObserver();
                }

                ObserverState = ObserverStates.Running;

                // We want the first update immediately.
                updateTime = 0;
            }
        }
 private void Internal_SetVolumeAsAxisAlignedBox(IntPtr observer, Vector3 origin, Vector3 extents)
 {
     SurfaceObserver.INTERNAL_CALL_Internal_SetVolumeAsAxisAlignedBox(this, observer, ref origin, ref extents);
 }
 private static extern void INTERNAL_CALL_Internal_SetVolumeAsSphere(SurfaceObserver self, IntPtr observer, ref Vector3 origin, float radiusMeters);
 private static extern void INTERNAL_CALL_Internal_SetVolumeAsOrientedBox(SurfaceObserver self, IntPtr observer, ref Vector3 origin, ref Vector3 extents, ref Quaternion orientation);
 private static extern void INTERNAL_CALL_Internal_SetVolumeAsOrientedBox(SurfaceObserver self, IntPtr observer, ref Vector3 origin, ref Vector3 extents, ref Quaternion orientation);
 private static extern void INTERNAL_CALL_Internal_SetVolumeAsAxisAlignedBox(SurfaceObserver self, IntPtr observer, ref Vector3 origin, ref Vector3 extents);
 private static extern void INTERNAL_CALL_Internal_Create(SurfaceObserver self, out IntPtr value);
        /// <summary>
        /// Called when the GameObject is unloaded.
        /// </summary>
        private void OnDestroy()
        {
            // Stop the observer.
            StopObserving();

            observer.Dispose();
            observer = null;

            // Clear our surface mesh collection.
            surfaces.Clear();
        }
 private void Awake()
 {
     observer = new SurfaceObserver();
     ObserverState = ObserverStates.Stopped;
 }
 private static extern void INTERNAL_CALL_Internal_SetVolumeAsSphere(SurfaceObserver self, IntPtr observer, ref Vector3 origin, float radiusMeters);
        protected override void Awake()
        {
            base.Awake();

            observer = new SurfaceObserver();
            ObserverState = ObserverStates.Stopped;
            observerOrigin = Vector3.zero;
        }