27 lines
751 B
C#
27 lines
751 B
C#
using BrewMonster.Scripts;
|
|
using UnityEngine;
|
|
using UnityEngine.AddressableAssets;
|
|
|
|
public class AddressableObject : MonoBehaviour
|
|
{
|
|
public string assetPath;
|
|
|
|
public async void LoadAsset()
|
|
{
|
|
var model = await AddressableManager.Instance.LoadPrefabAsync(assetPath);
|
|
if (model != null)
|
|
{
|
|
var modelTransform = model.transform;
|
|
modelTransform.SetParent(transform);
|
|
modelTransform.localPosition = Vector3.zero;
|
|
modelTransform.localRotation = Quaternion.identity;
|
|
modelTransform.localScale = Vector3.one;
|
|
model.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void UnloadAsset()
|
|
{
|
|
AddressableManager.Instance.ReleaseAsset(assetPath);
|
|
}
|
|
} |