I have followed Trever’s Save and Load System tutorial part 1 and 2 since my game won’t need more save slots (https://youtu.be/aUi9aijvpgs?si=g65R4UurYAgUK9fq). Currently my game needs to save player’s coin amount, each time the player has finished a minigame, they got some coins. I have tested in my Unity that when I changed scene the coin amount was saved (it works totally fine). The problem is that when I build my game for android and tested it in my phone (Samsung S21 FE), the coin gained from minigame won’t saved when the player change scenes. For example, after playing minigame A, I got 100 coins and it shown in the UI of the end game that my coin amoun has been increased. After the minigame ends, I have 2 choices, go back to main screen scene or reload the current minigame scene to play it again. Either choice is loading a new scene right? Now the problem is that either choice I have choosen, my coin amount is then reset back into 0. I don’t have any clue to fix this since the coin saved properly in development. I need this to be fixed ASAP since this is for my uni project and the deadline should be in one week. I will provide my CoinManager script where it handles the player coin amount in game.
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class CoinManager : MonoBehaviour, IDataPersistence
{
public static CoinManager Instance;
public int coinAmount;
private void Awake()
{
// If there is an instance, and it's not me, delete myself.
if (Instance != null && Instance != this)
{
Destroy(gameObject);
}
else
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
}
private void Start()
{
updateUI();
}
public void LoadData(GameData data)
{
this.coinAmount = data.coinAmount;
CoinManager.Instance.updateUI();
}
public void SaveData(ref GameData data)
{
data.coinAmount = this.coinAmount;
}
public void addCoin(int coinValue)
{
coinAmount += coinValue;
updateUI();
}
public bool canSubstractCoin(int coinValue)
{
return coinAmount >= coinValue;
}
public void substractCoin(int coinValue)
{
if(coinAmount < coinValue)
{
Debug.Log("Coin amount not enough to be substracted by " + coinValue + ".\nCoin Amount value remains = " + coinAmount);
return;
}
coinAmount -= coinValue;
updateUI();
}
public void updateUI()
{
CoinUI coin = FindAnyObjectByType<CoinUI>();
if (coin)
{
coin.setText(coinAmount.ToString());
}
}
}
that is my CoinManager script, it SaveData method is inherited from IDataPersistence that should be called when SceneUnloaded from my DataPersistenceManager object. The script for DataPersistenManager is the same as Trevor’s shown in his tutorial and yet I don’t know how to fix this problem in Android build ![]()

