File tree Expand file tree Collapse file tree 2 files changed +13
-18
lines changed
Expand file tree Collapse file tree 2 files changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -202,29 +202,19 @@ private bool CreateCameraObjects(string newCameraName = null)
202202 }
203203 }
204204
205- private void CleanupCameraObjects ( )
205+ public void CleanupCameraObjects ( )
206206 {
207- if ( enabled )
207+ for ( int i = 0 ; i < cameraObject . Length ; i ++ )
208208 {
209- for ( int i = 0 ; i < cameraObject . Length ; i ++ )
209+ if ( cameraObject [ i ] != null )
210210 {
211- try
212- {
213- UnityEngine . Object . Destroy ( cameraObject [ i ] ) ;
214- // Analysis disable once EmptyGeneralCatchClause
215- }
216- catch
217- {
218- // Yes, that's really what it's supposed to be doing.
219- }
220- finally
221- {
222- cameraObject [ i ] = null ;
223- }
211+ UnityEngine . Object . Destroy ( cameraObject [ i ] ) ;
224212 }
225- enabled = false ;
226- //JUtil.LogMessage(this, "Turning camera off.") ;
213+
214+ cameraObject [ i ] = null ;
227215 }
216+
217+ enabled = false ;
228218 cameraPart = null ;
229219 cameraTransform = null ;
230220 }
Original file line number Diff line number Diff line change @@ -394,6 +394,11 @@ public override void OnUpdate()
394394
395395 public void OnDestroy ( )
396396 {
397+ if ( cameraObject != null )
398+ {
399+ cameraObject . CleanupCameraObjects ( ) ;
400+ cameraObject = null ;
401+ }
397402 if ( homeCrosshairMaterial != null )
398403 {
399404 UnityEngine . Object . Destroy ( homeCrosshairMaterial ) ;
You can’t perform that action at this time.
0 commit comments