File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
org.mixedrealitytoolkit.input/InteractionModes
org.mixedrealitytoolkit.spatialmanipulation/BoundsControl
org.mixedrealitytoolkit.uxcore/Interop Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -298,6 +298,17 @@ private void Awake()
298298 InitializeInteractionModeDetectors ( ) ;
299299 }
300300
301+ /// <summary>
302+ /// A Unity event function that is called when the script component has been destroyed.
303+ /// </summary>
304+ private void OnDestroy ( )
305+ {
306+ if ( InteractionManager != null )
307+ {
308+ InteractionManager . interactorRegistered -= OnInteractorRegistered ;
309+ }
310+ }
311+
301312 /// <summary>
302313 /// A Unity Editor only event function that is called when the script is loaded or a value changes in the Unity Inspector.
303314 /// </summary>
Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ internal static Bounds CalculateBounds(
100100 finalBounds . Encapsulate ( root . InverseTransformPoint ( totalBoundsCorners [ i ] ) ) ;
101101 }
102102
103+ totalBoundsCorners . Clear ( ) ;
104+ childTransforms . Clear ( ) ; // Avoid keeping reference to Unity objects to avoid "Leaked Memory Shell"
103105 return finalBounds ;
104106 }
105107
Original file line number Diff line number Diff line change @@ -162,6 +162,19 @@ protected override void OnDisable()
162162 }
163163 }
164164
165+ /// <summary>
166+ /// A Unity event function that is called when the script component has been destroyed.
167+ /// </summary>
168+ protected override void OnDestroy ( )
169+ {
170+ base . OnDestroy ( ) ;
171+ if ( InteractionManager != null )
172+ {
173+ InteractionManager . interactorRegistered -= OnInteractorRegistered ;
174+ InteractionManager . interactorUnregistered -= OnInteractorUnregistered ;
175+ }
176+ }
177+
165178 /// <summary>
166179 /// Called when a an <see cref="IXRInteractor"/> is registered with a Unity <see cref="XRInteractionManager"/>.
167180 /// </summary>
You can’t perform that action at this time.
0 commit comments