Change Inspector value permanently through code?

I have 10 levels that all share the same script. I have a public bool variable called WinTreasure.
If this is true, when the player beats the level they will win a treasure.

This works fine. But what I need to happen is when the player wins the treasure, and then plays that same level again, they will NOT win a treasure. So if there was a way to adjust an inspector value permanently like (WinTreasure to false)after a treasure has been won that would be great.

I would prefer NOT to use PlayerPrefs. I would also prefer NOT to have to write level specific code (i.e. If level1.tag == “alreadywontreasure” then don’t drop treasure).

I know there must be a simple way of doing this but my mind is drawing blank.

It sounds like what you’re looking for is basic ‘save/load game’ functionality. I don’t have any specific suggestions, but I know this topic has been discussed quite a bit in the past; as such, a forum search for ‘save load game’ (or a similar phrase) will probably return some relevant threads.

How is the ‘winTreasure’ public? Is it attached to some class or object?

If so can’t you just reinitialize that object when a new scene is loaded?

i.e. (sorry c#)

public class TreasureLevel : MonoBehaviour
{
    bool winTreasure;

    public void Initialize()
    {
        winTreasure = false;
    }

    public void LoadNewLevel(int levelIndex)
    {
        // do level loading code here
       Initialize();
    }
}