浏览代码

Added listener to scene ready event in spawn manager

/main
Amel Negra 4 年前
当前提交
33c5fde8
共有 1 个文件被更改,包括 20 次插入1 次删除
  1. 21
      UOP1_Project/Assets/Scripts/SpawnSystem.cs

21
UOP1_Project/Assets/Scripts/SpawnSystem.cs


[Header("Scene References")]
[SerializeField] private Transform[] _spawnLocations;
void Start()
[Header("Scene Ready Event")]
[SerializeField] private VoidEventChannelSO _OnSceneReady = default; //Raised when the scene is loaded and set active
private void OnEnable()
{
if (_OnSceneReady != null)
{
_OnSceneReady.OnEventRaised += SpawnPlayer;
}
}
private void OnDisable()
{
if (_OnSceneReady != null)
{
_OnSceneReady.OnEventRaised -= SpawnPlayer;
}
}
private void SpawnPlayer()
{
Spawn(_defaultSpawnIndex);
}

正在加载...
取消
保存