您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

29 行
797 B

using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class PlayerConfigurator : MonoBehaviour
{
[SerializeField]
private Transform m_HatAnchor;
// Start is called before the first frame update
void Start()
{
//TODO: Remove this random stuff, just for testing atm
SetHat(string.Format("Hat{0:00}", UnityEngine.Random.Range(0, 4)));
}
// TODO: Change the string parameter
public void SetHat(string hatKey)
{
Addressables.InstantiateAsync(hatKey, m_HatAnchor, false).Completed += OnHatInstantiated;
}
// TOASK: Where to unsubscribe
private void OnHatInstantiated(AsyncOperationHandle<GameObject> obj)
{
Debug.Log("Hat Instantiated");
}
}