Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Release(Object)

Unloads an asset previously loaded from a Resources folder.
Read time 1 minuteLast updated 12 days ago

Definition

public void Release(Object asset)

Parameters

asset

The asset to unload.

Remarks

Releases the Resources reference so the asset can be unloaded when nothing else uses it. Pass an asset returned by one of the load methods.
Release a loaded asset once it is no longer needed.

Examples

using System.Threading;using Unity.Localization.Providers;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceFolderProviderReleaseExample { public async Awaitable Run() { var provider = new ResourceFolderProvider(); var icon = await provider.LoadAssetAsync<Sprite>( new AssetKey("UI/Icons/Settings", typeof(Sprite)), CancellationToken.None); if (icon != null) provider.Release(icon); } }}