Load() public method

Loads the SpatialMapping mesh from the specified file.
public Load ( string fileName ) : void
fileName string The name, without path or extension, of the file to load.
return void
示例#1
0
        // Use for initialization.
        private void Start()
        {
            PhysicsRaycastMask = 1 << PhysicsLayer;
            remoteMeshTarget   = FindObjectOfType <RemoteMeshTarget>();

#if !UNITY_EDITOR
            StartObserver();
#endif

#if UNITY_EDITOR
            fileSurfaceObserver = GetComponent <FileSurfaceObserver>();

            if (fileSurfaceObserver != null)
            {
                // In the Unity editor, try loading a saved mesh.
                fileSurfaceObserver.Load(fileSurfaceObserver.MeshFileName);

                if (fileSurfaceObserver.GetMeshFilters().Count > 0)
                {
                    SetSpatialMappingSource(fileSurfaceObserver);
                }
                else if (remoteMeshTarget != null)
                {
                    SetSpatialMappingSource(remoteMeshTarget);
                }
            }
#endif
        }
        /// <summary>
        /// Instructs the SurfaceObserver to start updating the SpatialMapping mesh.
        /// </summary>
        public void StartObserver()
        {
#if !UNITY_EDITOR
            if (!IsObserverRunning())
            {
                surfaceObserver.StartObserving();
                StartTime = Time.time;
            }
#elif UNITY_EDITOR
            fileSurfaceObserver = GetComponent <FileSurfaceObserver>();

            if (fileSurfaceObserver != null)
            {
                // In the Unity editor, try loading a saved mesh.
                fileSurfaceObserver.Load(fileSurfaceObserver.MeshFileName);

                if (fileSurfaceObserver.GetMeshFilters().Count > 0)
                {
                    SetSpatialMappingSource(fileSurfaceObserver);
                }
                else if (remoteMeshTarget != null)
                {
                    SetSpatialMappingSource(remoteMeshTarget);
                }
            }
#endif
        }
示例#3
0
        // Called every frame.
        private void Update()
        {
            // There are a few keyboard commands we will add when in the editor.
#if UNITY_EDITOR
            // F - to use the 'file' sourced mesh.
            if (Input.GetKeyUp(KeyCode.B))
            {
                SpatialMappingManager.Instance.SetSpatialMappingSource(fileSurfaceObserver);
            }

            // S - saves the active mesh
            if (Input.GetKeyUp(KeyCode.M))
            {
                MeshSaver.Save(fileSurfaceObserver.MeshFileName, SpatialMappingManager.Instance.GetMeshes());
            }

            // L - loads the previously saved mesh into the file source.
            if (Input.GetKeyUp(KeyCode.L))
            {
                fileSurfaceObserver.Load(fileSurfaceObserver.MeshFileName);
            }
#endif
        }