H
H
Habrnaunity2020-12-21 15:22:08
Unity
Habrnaunity, 2020-12-21 15:22:08

How to save data between scenes in unity?

5fe08de69852b903276103.png

Immediately I say I'm an amateur ...
I wrote these lines to save the data (health, damage, etc.) for the next scene. I attached this script (InfoData), for example, to the main camera (I tried it and not to it)

The button (which, if pressed, causes damage) refers to the main camera (because there is a script with the necessary data in it.)

5fe08eede5f90865713173.png

BUT when the scene changes, this button will not access anything
5fe08f145e5bb397504195.png

And so in all buttons, animations, etc.

The data is saved, but I can’t access it, because the buttons do not see the main camera of the FIRST scene, and the SECOND main camera has completely disappeared (but it’s not needed, because it contains old data).

In what ways can I use the same data in different scenes?
If you save everything else (for example, throw the script into the canvas, where all the buttons and pictures are) too, then I already save everything, and all my scenes become the same.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-12-21
@freeExec

And what's that?
5fe097014c368442139207.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question