File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Assets/HoloToolkit/Utilities/Scripts Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -141,27 +141,31 @@ public void RemoveAnchor(GameObject gameObjectToUnanchor)
141141 /// </summary>
142142 public void RemoveAllAnchors ( )
143143 {
144+ SpatialMappingManager spatialMappingManager = SpatialMappingManager . Instance ;
145+
144146 // This case is unexpected, but just in case.
145147 if ( AnchorStore == null )
146148 {
147149 Debug . LogError ( "remove all anchors called before anchor store is ready." ) ;
148150 }
149151
150152 WorldAnchor [ ] anchors = FindObjectsOfType < WorldAnchor > ( ) ;
151- SpatialMappingManager spatialMappingManager = FindObjectOfType < SpatialMappingManager > ( ) ;
152153
153154 if ( anchors != null )
154155 {
155156 foreach ( WorldAnchor anchor in anchors )
156157 {
157- //Don't remove SpatialMapping anchors
158- if ( anchor . gameObject . transform . parent . gameObject != spatialMappingManager . gameObject )
158+ // Don't remove SpatialMapping anchors if exists
159+ if ( spatialMappingManager == null ||
160+ anchor . gameObject . transform . parent . gameObject != spatialMappingManager . gameObject )
161+ {
159162 anchorOperations . Enqueue ( new Unity . WorldAnchorManager . AnchorAttachmentInfo ( )
160163 {
161164 AnchorName = anchor . name ,
162165 GameObjectToAnchor = anchor . gameObject ,
163166 Operation = AnchorOperation . Delete
164167 } ) ;
168+ }
165169 }
166170 }
167171 }
You can’t perform that action at this time.
0 commit comments