File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Assets/HoloToolkit/Utilities/Scripts Expand file tree Collapse file tree 1 file changed +31
-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,36 @@ 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+ // This case is unexpected, but just in case.
145+ if ( AnchorStore == null )
146+ {
147+ Debug . LogError ( "remove all anchors called before anchor store is ready." ) ;
148+ }
149+
150+ WorldAnchor [ ] anchors = FindObjectsOfType < WorldAnchor > ( ) ;
151+ SpatialMappingManager spatialMappingManager = FindObjectOfType < SpatialMappingManager > ( ) ;
152+
153+ if ( anchors != null )
154+ {
155+ foreach ( WorldAnchor anchor in anchors )
156+ {
157+ //Don't remove SpatialMapping anchors
158+ if ( anchor . gameObject . transform . parent . gameObject != spatialMappingManager . gameObject )
159+ anchorOperations . Enqueue ( new Unity . WorldAnchorManager . AnchorAttachmentInfo ( )
160+ {
161+ AnchorName = anchor . name ,
162+ GameObjectToAnchor = anchor . gameObject ,
163+ Operation = AnchorOperation . Delete
164+ } ) ;
165+ }
166+ }
167+ }
168+
138169 /// <summary>
139170 /// Function that actually adds the anchor to the game object.
140171 /// </summary>
You can’t perform that action at this time.
0 commit comments