Getting a double save message

Hi!
I’m getting a double save message after I press S
doublesave
any idea why is this happening?

And here is the code for the SavingWrapper:

using RPG.Saving;
using UnityEngine;

namespace RPG.SceneManagement
{
    public class SavingWrapper : MonoBehaviour
    {
        const string defaultSaveFile = "save";

        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.L))
            {
                Load();
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                Save();
            }
        }

        private void Load()
        {
            //call to the saving system load
            GetComponent<SavingSystem>().Load(defaultSaveFile);
        }

        private void Save()
        {
            GetComponent<SavingSystem>().Save(defaultSaveFile);
        }
    }
}

thanks!

My best guess is that you have two SavingWrappers in the scene.

Add this method just to check:

public void Awake()
{
    Debug.Log($"{gameObject.name} SavingWrapper reporting for duty.");
}

If you see two of these logs on Awake() then there’s a second GameObject (which the Log will conveniently name for you) with a SavingWrapper on it.

Thank you!

Privacy & Terms