H
H
Herman Coffman2020-06-29 15:47:19
C++ / C#
Herman Coffman, 2020-06-29 15:47:19

How to save a variable when reloading a scene?

Hello.
The question is: is there a variable

Money
and variables responsible for purchased costumes.
How to save them when reloading the scene and can writing to a separate file help with this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2020-06-29
@Gera01

1) There are objects marked DontDestroyOnLoad
2) There are PlayerPrefs
3) At worst, you can use files

G
GFX Data, 2020-07-02
@ShockWave2048

Static fields and classes.

public static int Money = 0;

public static class Account
{
    private static List<Suit> Suits = new List<Suit>(); 
}

Only within the runtime session, when the game is reloaded, everything will be reset.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question