Store Playerdata in Scriptable Object

Hello,

Actually i try to use Scriptable Object as Data Container.
So far as good he raise up the Variable as example a Counter

I destroy a Brick and he tell the Scriptable Object i destroyed a brick and increase the int by 1
Working Fine

But as soon i stop Playing an restart the Game all Data in the Scriptable Object are gone.
I was thinking Data in Scriptable Object are persisant and stay at the Values.
Because i need Access from various Scripts i made a PlayerManager:

public Player player;
    public static PlayerManager playerManager;

    private void Awake()
    {
        playerManager = this;
        DontDestroyOnLoad(this);
    }

he is the Reference in every Scene to get Access to the Player Scriptable Object which only look like this:

using UnityEngine;

[CreateAssetMenu(fileName = "Player", menuName = "Player")]
public class Player : ScriptableObject
{
    public int brickCounter;
    public float score;
    public float highscore;
}

My Idea behind that is simple, sure i can store that information in PlayerPrefs, but PlayerPrefs are susceptible to Cheater and i someone Know where to look he find them easy. Sure i can make as example a JSON and make a big Security behind that all, but for a small game like mine im not sure if its economic to make so much effort to prevent player from cheating.


So when i set Data in a Scriptable Object like i say in Inspector brickCounter = 100;
i close the Game and restart the game the brickCounter is still at 100;


But if i start the game play a bit and destroy some Bricks the Counter go from 100 to 105 (i destroyed now 5 brick) then i can see in the Scriptable Object its 105. But as soon i stop the Game and start again it is set back to 100. Why is that? How can i solve this?


Hope someone can give me a hint or idea to solve it different way.
I have EasySave2 Asset but as i said… its a small game…

As i go through my Code i consider about.


My PlayerManager is a static so i have access all over the scene to it.
Means that my Player player (the Scriptable Object) is also a static? That would explain to me why he reset the Scriptable Object after i restart the Game?

If i make it non Static and make something like FindGameObject would this work?


Mhh okay i tried to make my PlayerManager non static and get in all Scripts a reference to that PlayerManager but sadly he still delete all information if i restart the Game/Unity

Hi,
the way I did it (also didnt want to use PlayerPrefs to save stuff) was by using the BinaryWriter/BinaryReader of the “System.IO” package.
This way I could hide the file wherever I wanted, and since only you know wich bit refears to wich piece of information (CheatEngine and whatnot can still figure this out), I felt somewhat safe about cheaters.
But if you really want it to be cheatsafe then you can´t save it locally either way.