File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Assets/HoloToolkit/Utilities/Scripts Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 55using UnityEngine ;
66using UnityEngine . VR . WSA . Persistence ;
77using UnityEngine . VR . WSA ;
8+ using HoloToolkit . Unity . SpatialMapping ;
89
910namespace HoloToolkit . Unity
1011{
@@ -135,6 +136,40 @@ public void RemoveAnchor(GameObject gameObjectToUnanchor)
135136 } ) ;
136137 }
137138
139+ /// <summary>
140+ /// Removes all anchors from the scene and deletes them from the anchor store.
141+ /// </summary>
142+ public void RemoveAllAnchors ( )
143+ {
144+ SpatialMappingManager spatialMappingManager = SpatialMappingManager . Instance ;
145+
146+ // This case is unexpected, but just in case.
147+ if ( AnchorStore == null )
148+ {
149+ Debug . LogError ( "remove all anchors called before anchor store is ready." ) ;
150+ }
151+
152+ WorldAnchor [ ] anchors = FindObjectsOfType < WorldAnchor > ( ) ;
153+
154+ if ( anchors != null )
155+ {
156+ foreach ( WorldAnchor anchor in anchors )
157+ {
158+ // Don't remove SpatialMapping anchors if exists
159+ if ( spatialMappingManager == null ||
160+ anchor . gameObject . transform . parent . gameObject != spatialMappingManager . gameObject )
161+ {
162+ anchorOperations . Enqueue ( new AnchorAttachmentInfo ( )
163+ {
164+ AnchorName = anchor . name ,
165+ GameObjectToAnchor = anchor . gameObject ,
166+ Operation = AnchorOperation . Delete
167+ } ) ;
168+ }
169+ }
170+ }
171+ }
172+
138173 /// <summary>
139174 /// Function that actually adds the anchor to the game object.
140175 /// </summary>
You can’t perform that action at this time.
0 commit comments