using UnityEngine; using System.Linq; public class ES3SaveController : MonoBehaviour { [Header("Defaults")] [Range(0, 9)] public int defaultSlot = 0; // ---------- Save/Load/Delete ---------- public void SaveNow() => SaveNowToSlot(defaultSlot); public void LoadNow() => LoadNowFromSlot(defaultSlot); public void DeleteNow() => DeleteSlot(defaultSlot); public void SaveNowToSlot(int slot) { ES3GameStore.Save(slot); Debug.Log($"[ES3] Saved profile '{ES3ProfileManager.Instance.ActiveProfileId}' slot {slot}"); } public void LoadNowFromSlot(int slot) { if (!ES3GameStore.Load(slot)) Debug.LogWarning($"[ES3] No save for profile '{ES3ProfileManager.Instance.ActiveProfileId}' slot {slot}"); } public void DeleteSlot(int slot) { ES3GameStore.Delete(slot); Debug.Log($"[ES3] Deleted profile '{ES3ProfileManager.Instance.ActiveProfileId}' slot {slot}"); } // ---------- Profile API for UI ---------- public void CreateProfile(string displayName) { var p = ES3ProfileManager.Instance.CreateProfile(displayName); ES3ProfileManager.Instance.SetActiveProfile(p.id); Debug.Log($"[ES3] Created & selected profile '{p.displayName}' ({p.id})"); } public void DeleteActiveProfile() { var id = ES3ProfileManager.Instance.ActiveProfileId; ES3ProfileManager.Instance.DeleteProfile(id); Debug.Log($"[ES3] Deleted profile '{id}'"); } public void SetActiveProfileById(string id) { ES3ProfileManager.Instance.SetActiveProfile(id); Debug.Log($"[ES3] Active profile set to '{id}'"); } // Convenience for dropdowns: pass display name instead of id. public void SetActiveProfileByDisplay(string displayName) { var pm = ES3ProfileManager.Instance; var p = pm.Profiles.FirstOrDefault(x => x.displayName == displayName); if (p != null) pm.SetActiveProfile(p.id); } }