How can I access the Save/Load functions from a script that is on another scene ?

I have two scene : Main Menu, Game
On the Main Menu I have also a two buttons : Save,Load

And two scripts :

Save System :

using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

public static class SaveSystem
{
    public static void SavePlayer(Player player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string path = Application.persistentDataPath + "/player.bin";
        FileStream stream = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(player);

        formatter.Serialize(stream, data);
        stream.Close();
    }

    public static PlayerData LoadPlayer()
    {
        string path = Application.persistentDataPath + "/player.bin";
        if(File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream stream = new FileStream(path, FileMode.Open);

            PlayerData data = formatter.Deserialize(stream) as PlayerData;
            stream.Close();

            return data;
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return null;
        }
    }
}

And Player :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
   public void SavePlayer()
    {
        SaveSystem.SavePlayer(this);
    }

    public void LoadPlayer()
    {
        PlayerData data = SaveSystem.LoadPlayer();

        Vector3 position;
        position.x = data.position[0];
        position.y = data.position[1];
        position.z = data.position[2];
        transform.position = position;
    }
}

The Player script is attached to the Player in the Game scene but now I can’t call or get access to the SavePlayer and LoadPlayer from the two buttons in the On Click events.

And another problem is that the Game scene is not all the time in the Hierarchy the Game scene is loaded when I click the Play button and then the Main Menu scene is not loaded and when I hit the escape key it’s loading the Main Menu scene but then the Game scene is not loaded.

So I wonder how should I and how can I make a reference between the buttons Save/Load and the functions SavePlayer/LoadPLayer ?

EDIT: I think I misunderstood your question so I deleted my previous response.

Are you trying to just connect the LOAD/SAVE button to those static methods in your SaveSystem?

Yes that’s what I want to do. I want to be able from the main menu scene save load buttons to save and load the player position for example either using the static methods or the methods from the Player script. The problem is that the player is on the other scene. But you got the idea. In general I want to save/load the player position. The problem is that the player is on one scene and the buttons on another scene and this two scene also switch when the main menu is loaded the game scene is removed not loaded and when the game scene is loaded the main menu is not.,

In other words I want to save/load the player position from another scene.

There’s a few helpful patterns to use here.

One is to make a central data manager that keeps track of everything that MIGHT be saved in the game. This would either be static or a singleton, and the Player (and anything else that has save state data) would send their data to this object, or just use it to store the data.

Finally you would have a separate mechanism that is an MonoBehavior instance that can connect functions to those buttons, and then when pressed, they would go to the central data manager and get all the data to write out.

Another pattern is to have a load/save manager listener ALWAYS present, and just hide the buttons in the load/save UI when you don’t need it.

Another pattern is the one I set up with my Datasacks module: it lets you write code that subscribes to things like “SaveButton” and then put button responder scripts on your buttons, and via the Datasack Userintent mechanism (see docs in the package), these buttons can signal any listener that something interesting has happened.

Datasacks is presently hosted at these locations:

https://bitbucket.org/kurtdekker/datasacks

There are several button and responder code examples in the supplied example clicker game, and this gives you kind of an overall view of how the mechanism is used.