Firstborn/Library/PackageCache/com.unity.addressables@1.19.19/Tests/Editor/DocExampleCode/InstantiateReference.cs

23 lines
583 B
C#
Raw Normal View History

namespace AddressableAssets.DocExampleCode
{
#region doc_InstantiateReference
using UnityEngine;
using UnityEngine.AddressableAssets;
internal class InstantiateReference : MonoBehaviour
{
[SerializeField]
private AssetReferenceGameObject reference;
void Start() {
if (reference != null)
reference.InstantiateAsync(this.transform);
}
private void OnDestroy() {
if (reference != null && reference.IsValid())
reference.ReleaseAsset();
}
}
#endregion
}