wave-harmonic / crest

A class-leading water system implemented in Unity
MIT License
3.4k stars 475 forks source link

Release Ocean Renderer resources in OnDestroy #1114

Closed daleeidd closed 1 year ago

daleeidd commented 1 year ago

Fixes #751

Releasing resources in OnDisable means rebuilding everything in OnEnable which makes toggling the OR impractical. Several use cases have emerged which warrants the change. OnDisable is always used in edit mode as OnDestroy is not reliably called there.

A debug option (Destroy Resources In On Disable) will revert this behaviour if needed.

Other components could benefit from also adopting this change, but the OR is the primary pain point due to mesh construction so not expanding the scope beyond the OR.