using DG.Tweening; using Michsky.UI.Heat; using Obvious.Soap; using UFS3.Management; using UnityEngine; using UnityEngine.SceneManagement; public class UI_LoadGame : MonoBehaviour { public PlayerProfile PlayerProfile; public BoolVariable IsInGameMainMenuEnabled; [SerializeField] private UI_LoadSlotButton _SlotTemplate; [SerializeField] private Transform _SlotTemplateParent; [SerializeField] private Transform _SlotAddProfile; [SerializeField] private CanvasGroup _FadeCanvas; private void OnEnable() { PlayerProfile.OnProfileCreated += PlayerProfile_OnProfileCreated; _ = PlayerProfile.GetProfiles().LongLength; string[] profiles = PlayerProfile.GetProfiles(); foreach (string profileName in profiles) { Object.Instantiate(_SlotTemplate, _SlotTemplateParent).Initialize(profileName); } _SlotAddProfile.SetAsLastSibling(); } private void OnDisable() { PlayerProfile.OnProfileCreated -= PlayerProfile_OnProfileCreated; UI_LoadSlotButton[] componentsInChildren = _SlotTemplateParent.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy(componentsInChildren[i].gameObject); } } private void PlayerProfile_OnProfileCreated() { OnLoadSlot_ProfileLoaded(); } public void OnLoadSlot_ProfileLoaded() { float duration = 1f; _FadeCanvas.gameObject.SetActive(value: true); _FadeCanvas.DOFade(1f, duration).OnComplete(delegate { MenuManager.bypassSplashScreen = false; UFS3.Management.SceneManager.LoadAsync("Main Menu", LoadSceneMode.Single); }); } }