Loading Game

Announcements, support questions, and discussion for the Dialogue System.
jrose1184
Posts: 35
Joined: Mon Jan 22, 2024 2:35 pm

Re: Loading Game

Post by jrose1184 »

Hi i have this weird bug going on. If i load my data it keeps returning me to my home screen and it only happens in this code

if (SaveSystem.HasSavedGameInSlot(1))
{
SaveSystem.LoadFromSlot(1);
Debug.Log("im getting here 6");
}

How can i see what data is in this slot incase some how its saving that returned screen,

I am woundering if when i call save to slot its some how adding the wrong scene some where.
jrose1184
Posts: 35
Joined: Mon Jan 22, 2024 2:35 pm

Re: Loading Game

Post by jrose1184 »

just fyi this is what my saving is doing

Code: Select all

 
 public void SaveGame()
    {
     Debug.Log("im saving the game");
     PixelCrushers.SaveSystem.SaveToSlot(1);
     SaveManager.SavePlayerData(PlayerController.instance.transform.position);
    }
  public static void SavePlayerData(Vector3 position)
    {
        // Show saving indicator
        ShowSavingIndicator();

        // Create PlayerData object
        PlayerData data = new PlayerData(position);

        // Add IDs of currently destroyed objects
        AddDestroyedObjectIDs();

        // Add destroyed object IDs to data
        data.destroyedObjectIDs = new List<string>(GameManager.instance.destroyedObjectIDs);
        
        foreach (string id in data.destroyedObjectIDs)
        {
            UniqueID destroyedObject = FindUniqueObjectByID(id);
            if (destroyedObject != null)
            {
                Debug.Log("Destroyed Object Name: " + destroyedObject.gameObject.name + ", ID: " + id);
            }
        }

        // Convert PlayerData to JSON and save to file
        string json = JsonUtility.ToJson(data);
        string path = Application.persistentDataPath + "/playerData.json";
        File.WriteAllText(path, json);

        // Hide saving indicator after saving is complete
        HideSavingIndicator();
    }
jrose1184
Posts: 35
Joined: Mon Jan 22, 2024 2:35 pm

Re: Loading Game

Post by jrose1184 »

Ok i found the issue the saveslot is saving the scene - how do i turn it off at the moment i just commented it out

Code: Select all

 public static void LoadGame(SavedGameData savedGameData)
        {
            if (savedGameData == null)
            {
                if (Debug.isDebugBuild) Debug.LogWarning("SaveSystem.LoadGame received null saved game data. Not loading.");
            }
            /*else if (saveCurrentScene)
            {
                instance.StartCoroutine(LoadSceneCoroutine(savedGameData, null, SceneValidationMode.LoadingSavedGame));
            }*/
            else
            {
                ApplySavedGameData(savedGameData);
            }
        }
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Loading Game

Post by Tony Li »

Hi,

Inspect the Save System component and UNtick "Save Current Scene".
jrose1184
Posts: 35
Joined: Mon Jan 22, 2024 2:35 pm

Re: Loading Game

Post by jrose1184 »

Thanks for all your help reeally appreciate your time
User avatar
Tony Li
Posts: 22655
Joined: Thu Jul 18, 2013 1:27 pm

Re: Loading Game

Post by Tony Li »

Glad to help!
Post Reply