Skip to content

Commit 240e85e

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
File Surface Observer.cs added missing merge changes from master.
1 parent 8f6cd74 commit 240e85e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Assets/HoloToolkit/SpatialMapping/Scripts/RemoteMapping/FileSurfaceObserver.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ public class FileSurfaceObserver : SpatialMappingSource
1111
[Tooltip("The file name to use when saving and loading meshes.")]
1212
public string MeshFileName = "roombackup";
1313

14+
[Tooltip("Key to press in editor to load a spatial mapping mesh from a .room file.")]
15+
public KeyCode LoadFileKey = KeyCode.L;
16+
17+
[Tooltip("Key to press in editor to save a spatial mapping mesh to file.")]
18+
public KeyCode SaveFileKey = KeyCode.S;
19+
1420
/// <summary>
1521
/// Loads the SpatialMapping mesh from the specified file.
1622
/// </summary>
@@ -59,5 +65,25 @@ public void Load(string fileName)
5965
Debug.Log("Failed to load " + fileName);
6066
}
6167
}
68+
69+
// Called every frame.
70+
private void Update()
71+
{
72+
// Keyboard commands for saving and loading a remotely generated mesh file.
73+
#if UNITY_EDITOR || UNITY_STANDALONE
74+
// S - saves the active mesh
75+
if (Input.GetKeyUp(KeyCode.S))
76+
{
77+
MeshSaver.Save(MeshFileName, SpatialMappingManager.Instance.GetMeshes());
78+
}
79+
80+
// L - loads the previously saved mesh into editor and sets it to be the spatial mapping source.
81+
if (Input.GetKeyUp(KeyCode.L))
82+
{
83+
SpatialMappingManager.Instance.SetSpatialMappingSource(this);
84+
Load(MeshFileName);
85+
}
86+
#endif
87+
}
6288
}
6389
}

0 commit comments

Comments
 (0)