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 @@ -319,6 +319,17 @@ private void Awake()
319319 InitializeInteractionModeDetectors ( ) ;
320320 }
321321
322+ /// <summary>
323+ /// A Unity event function that is called when the script component has been destroyed.
324+ /// </summary>
325+ private void OnDestroy ( )
326+ {
327+ if ( InteractionManager != null )
328+ {
329+ InteractionManager . interactorRegistered -= OnInteractorRegistered ;
330+ }
331+ }
332+
322333 /// <summary>
323334 /// A Unity Editor only event function that is called when the script is loaded or a value changes in the Unity Inspector.
324335 /// </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 @@ -164,6 +164,19 @@ protected override void OnDisable()
164164 }
165165 }
166166
167+ /// <summary>
168+ /// A Unity event function that is called when the script component has been destroyed.
169+ /// </summary>
170+ protected override void OnDestroy ( )
171+ {
172+ base . OnDestroy ( ) ;
173+ if ( InteractionManager != null )
174+ {
175+ InteractionManager . interactorRegistered -= OnInteractorRegistered ;
176+ InteractionManager . interactorUnregistered -= OnInteractorUnregistered ;
177+ }
178+ }
179+
167180 /// <summary>
168181 /// Called when a an <see cref="IXRInteractor"/> is registered with a Unity <see cref="XRInteractionManager"/>.
169182 /// </summary>
You can’t perform that action at this time.
0 commit comments