Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (observer == null)
            {
                observer = new UnityEngine.VR.WSA.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>
        /// Starts the Surface Observer.
        /// </summary>
        public void StartObserving()
        {
            if (observer == null)
            {
                observer = new UnityEngine.VR.WSA.SurfaceObserver();
                SwitchObservedVolume();
            }

            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()
        {
            StopObserving();

            if (observer != null)
            {
                observer.Dispose();
                observer = null;
            }

            if (outstandingMeshRequest != null)
            {
                CleanUpSurface(outstandingMeshRequest.Value);
                outstandingMeshRequest = null;
            }

            if (spareSurfaceObject != null)
            {
                CleanUpSurface(spareSurfaceObject.Value);
                spareSurfaceObject = null;
            }

            Cleanup();
        }