i have this error ;Assets\LastMan\GraphicOptions\LoadManager.cs(53,33): error CS0120: An object reference is required for the non-static field, method, or property 'SaveSystem.GetSaveFile(int)'
using UnityEngine;
using UnityEngine.UI;
using AC; // Namespace for Adventure Creator
using Michsky.MUIP;
using System.Collections.Generic;
public class LoadManager : MonoBehaviour
{
[Header("UI Elements")]
[SerializeField] private ButtonManager loadButton; // Using ButtonManager from Modern UI Pack
[SerializeField] private Transform saveSlotParent; // Parent object for save slots
[SerializeField] private GameObject saveSlotPrefab; // Prefab for save slots
private List<SaveFile> saveFiles = new List<SaveFile>();
private void Awake()
{
if (loadButton != null)
{
loadButton.buttonText = "Load";
loadButton.useCustomContent = true;
loadButton.onClick.AddListener(PopulateSaveSlots); // Populate the save slots list
}
PopulateSaveSlots();
}
private void LoadGame(int saveID)
{
if (saveID >= 0 && saveID < saveFiles.Count)
{
SaveFile saveFile = saveFiles[saveID];
if (saveFile != null)
{
SaveSystem.LoadGame(saveFile); // Load the game
Debug.Log("Game loaded from slot " + (saveID + 1));
}
}
}
private void PopulateSaveSlots()
{
foreach (Transform child in saveSlotParent)
{
Destroy(child.gameObject);
}
saveFiles.Clear();
int numSaves = Mathf.Min(SaveSystem.GetNumSlots()); // Limit to the number of save slots
for (int i = 0; i < numSaves; i++)
{
SaveFile saveFile = SaveSystem.GetSaveFile(i); // Retrieve save file by index
if (saveFile != null)
{
saveFiles.Add(saveFile);
GameObject slot = Instantiate(saveSlotPrefab, saveSlotParent);
ButtonManager slotButton = slot.GetComponent<ButtonManager>();
string saveLabel = SaveSystem.GetSaveSlotLabel(i, i, false); // Get the save slot label
slotButton.buttonText = saveLabel;
slotButton.useCustomContent = true;
int saveID = i; // Local variable to avoid issues with delegates
slotButton.onClick.AddListener(() => LoadGame(saveID));
}
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
The GetSaveFile function is non-static - you need to reference the KickStarter's instance of SaveSystem (instructions can be found here).
To fix, replace:
with:
1 more question i finished it but the issue i dont have multiple id profiles for my saving i made (i made it that player can pick 1 od 3 diffrent profiles name them and load save) saves loads work but only for autosafe profile rest when clicking load arent shown in list my scripts;
saving;
using UnityEngine;
using TMPro;
using AC; // Namespace for Adventure Creator
using Michsky.MUIP;
public class SaveManager : MonoBehaviour
{
[SerializeField] private ButtonManager[] saveButtons;
[SerializeField] private TMP_InputField[] profileNameInputs;
}
loading
using UnityEngine;
using TMPro;
using AC; // Namespace for Adventure Creator
using Michsky.MUIP;
using System.Diagnostics;
public class LoadManager : MonoBehaviour
{
[SerializeField] private ButtonManager[] loadButtons;
[SerializeField] private TMP_InputField[] profileNameInputs;
}
I'm sorry, but can you rephrase your issue? I'm not clear on your meaning. Screenshots will be welcome too, if possible.
i tried to do 3 separee profiles but i have json error now i have 4 separete scripts 1 for starting all 2cond for holding profiles 3rd and 4rth fore save load
using System.Diagnostics;
using UnityEngine;
public class StartManager : MonoBehaviour
{
public ProfileManager profileManager;
public SaveManager saveManager;
public LoadManager loadManager;
}
using UnityEngine;
using AC;
using System.IO;
using System.Diagnostics;
[System.Serializable]
public class ProfileData
{
public string profileName;
// Dodaj dodatkowe pola, które chcesz zapisać
}
public class ProfileManager : MonoBehaviour
{
public int profileNameVarID; // Global variable ID for the profile name in AC
}
using UnityEngine;
using TMPro;
using Michsky.MUIP; // Import Modern UI Pack
public class SaveManager : MonoBehaviour
{
public ProfileManager profileManager;
public TMP_InputField[] profileNameInputs; // Input fields for profile names
[SerializeField] private ButtonManager[] saveButtons; // Buttons for saving
}
using UnityEngine;
using TMPro;
using AC;
using Michsky.MUIP; // Import Modern UI Pack
public class LoadManager : MonoBehaviour
{
public ProfileManager profileManager;
public TMP_Text[] profileNameDisplays; // Text fields to display profile names
[SerializeField] private ButtonManager[] loadButtons; // Buttons for loading
}
not sure what to change i dont want do breake ac code just need 3 profiles separete
nvm i found what was the case i had selected as string not as object (my profile manager)
5 days of looking into code for nothing xD