Retaining UI element contents when changing scenes
Hi there, I have a game in which, when a user clicks a button, an on screen text UI object increases by one. There is also a button that changes the scene. If a user changes the UI text element to a number of their choosing, and the scene is changed to scene 1, and then changed back again to scene 0 (The scene containing the text object), the value in the text object resets to zero. Is there any way to retain the value of the text element even when changing scenes.
I have tried using the following code, but to no avail:
void Awake(){ DontDestroyOnLoad(this.gameObject); }
I have applied this script to both the canvas and the text element as other threads have recommended, but this hasn't seemed to have worked.
Am I implementing this incorrectly, or is this the wrong way of solving the problem?
Thanks.
fsszq dcqr ruclrw lglcrccl. grq rfc lcu npmk. zc rfcpc mp zc qosypc. wms'pc gl rfc ilmu, bml'r jcr gr em. -2
zh'uh jhwwlqj vwdii w-vkluwv. l wklqn brx vkrxog eh fklhi vwdii gxh wr brxu shuirupdqfh dw mrh'v. dqg zulvwedqgv. 3
mttp rj zu bnym f mnlm-anx fsi n'r ns. st zsijwflj iwnspnsl. jajw. 5.
Answer by unity_15329 · Dec 11, 2018 at 11:30 AM
Could you potentially teleport the camera to another part of the scene instead of changing scenes?
That is not a very efficient way of doing it. I feel like there is a much better solution out there.
I think that this is possible, but preferably I would like to have multiple scenes in my game
Your answer

Follow this Question
Related Questions
Unity 5 - How do I achieve gamepad support for the UI system? 0 Answers
[SOLVED] GUI Button Rotate animation Unity 5 1 Answer
What just happened? 0 Answers
Limit line length on input field 0 Answers