Search Feedback

0
votes

Destroy internal cleanup to happen after OnDestroy.

Runtime

-

-

Currently (as tested in 2018.1.9) calling Destroy(Object) causes Unity's internal references to be cleaned up immediately, even while waiting to destroy the whole object later. Using one of those references (like Graphic.canvas) in, say, LateUpdate causes a null reference exception, even though OnDestroy hasn't been called yet. This forces me to check whether that reference is null every frame, just to catch it the one frame it is destroyed.

My suggestion is to move the internal cleanup to after the OnDestroy call, instead of immediately when Destroy is called.

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(10797)

2D

(282)

Ads

(56)

AI & Navigation

(84)

Analytics

(133)

Animation

(396)

Asset Store

(356)

Asset Store Publisher

(17)

Assets

(544)

Audio

(185)

Cloud Build

(145)

Collaborate

(65)

Docs & Tutorials

(240)

Editor

(2513)

Everyplay

(19)

Game Performance Reporting

(22)

General

(981)

Graphics

(870)

GUI

(432)

Input

(173)

Licensing

(92)

Networking

(189)

Physics

(384)

Platforms

(442)

Profiling & Optimization

(85)

Runtime

(182)

Scripting

(1169)

Terrain

(172)

WebGL

(143)