Documentation

Unity Engine

Download Unity

Unity Engine

Dispose()

Releases the clip reference and the memory of the sampler.
Read time 1 minuteLast updated 4 hours ago

Definition

public void Dispose()

Remarks

Copies of the sampler share the same memory. Call this method on only one copy, and don't use the other copies afterward. A sampler from ClipSampler.Clone has its own memory, so this method doesn't affect it. This method has no effect on a default sampler.
If safety checks are enabled, a second call to this method throws an
ObjectDisposedException
on any copy. For a sampler that uses Allocator.Temp, the safety system doesn't detect that you use another copy after this call, as for other containers that use Allocator.Temp. The memory of the sampler stays valid until the end of the scope of the temporary allocations, but the clip data can be released. Using the copy on which you called
Dispose
throws a
NullReferenceException
.