Version: 2021.3

参数

disposing The flag to indicate whether the method call comes from a Dispose method or from a finalizer. A bool. When the value is true, the method call comes from a Dispose method. Otherwise, the method call comes from a finalizer.

描述

Disposes the view controller. Unity calls this method automatically when the view controller is no longer required, and its view will be removed from the window hierarchy.

Override this method to do any necessary clean up of your view controller, such as unsubscribing from events. You should always call the base implementation afterwards. You do not need to explicitly remove the view controller’s view from the hierarchy; Unity does this automatically when it disposes of the view controller.

For more information on the C# Dispose pattern, see Microsoft's documentation on Implementing dispose.

protected override void Dispose(bool disposing)
{
    if (disposing)
    {
        // Do any necessary clean up or freeing of managed resources.
    }

// Call the base implementation. base.Dispose(disposing); }