using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; // ReSharper disable once CheckNamespace namespace BlueWaterProject { public class RestartPopupUi : MonoBehaviour { private List currentCrewmateList; private void OnEnable() { // 씬이 로드될 때마다 OnSceneLoaded 메서드를 호출합니다. SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDisable() { // 이 오브젝트가 비활성화될 때 이벤트 핸들러를 제거합니다. SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnInteraction(InputValue value) { currentCrewmateList = GameManager.Inst.CurrentCrewmateList; var currentSceneIndex = SceneManager.GetActiveScene().buildIndex; SceneManager.LoadScene(currentSceneIndex); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { // 로딩 이후에 실행되어야 하는 코드를 여기에 작성합니다. var spawnController = FindAnyObjectByType(); foreach (var crewmate in currentCrewmateList) { spawnController.SetCrewmatePrefabIndex(crewmate.CrewmatePrefabIndex); spawnController.AddCrewmate(); } } } }