My characters do not save on the selected character image when i change screen it just sticks to one

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


[System.Serializable]
public class GameData
{
    public int money;
    public int owned;
}




public class ShopScript : MonoBehaviour
{

    public Sprite defaultcharacter;
    public Sprite character1;
    public Sprite character2;
    public Image selectedcharacter;
    public Text moneytext;
    public GameObject buybutton;
    public int priceofcharacter1;
    public int priceofcharacter2;

    public GameData gameData = new GameData();




    // Start is called before the first frame update
    void Start()
    {
        gameData = BinarySerializer.Load<GameData>("gamedata");

        if (gameData.owned == 1)
        {
            buybutton.SetActive(false);
        }

        if (gameData.owned == 2)
        {
            buybutton.SetActive(false);
        }
    }

    // Update is called once per frame
    void Update()
    {
        moneytext.text = "Money : " + gameData.money + " Coin";
    }

    public void selectcharacter()
    {
        selectedcharacter.GetComponent<Image>().sprite = defaultcharacter;
    }

    public void buycharacter1()
    {

        gameData.money -= priceofcharacter1;

        gameData.owned = 1;

        buybutton.SetActive(false);
    }

    public void buycharacter2()
    {
        gameData.money -= priceofcharacter2;

        gameData.owned = 2;

        buybutton.SetActive(false);
    }

    public void selectcharacter1()
    {
        selectedcharacter.GetComponent<Image>().sprite = character1;
    }

    public void selectcharacter2()
    {
        selectedcharacter.GetComponent<Image>().sprite = character2;
    }


    private void OnApplicationQuit()
    {
        BinarySerializer.Save<GameData>(gameData, "gamedata");
    }
}

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

If you are running a mobile device you can also see the console output. Google for how.