3_Project_Boost | Local version control | Game Engine library
kandi X-RAY | 3_Project_Boost Summary
kandi X-RAY | 3_Project_Boost Summary
Basic Particle Effects. Local version control. Basic UI & Menu. C# classes, function return values. Unity Components, coordinate systems, origins and anchor points, advanced prefabs. Level design. (Ref: PB_CU2)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of 3_Project_Boost
3_Project_Boost Key Features
3_Project_Boost Examples and Code Snippets
Community Discussions
Trending Discussions on 3_Project_Boost
QUESTION
I have a UI bug that I can not figure out. I wish to be able to carry my score over into each scene, while also having each scene independent of one another. If the player chooses to start the game in level 6 he should be able to do so with a clean scoreboard, same as starting at level 1. The score should proceed unitl to transfer until the player dies at which point the score should be set back to 0. To do this I've prefabbed my scoreboard and dropped it into every scene using the singleton pattern to make sure that there are no duplicate scoreboards in the scene. While trying to access my score text UI of type Text using UnityEngine.UI I receive a null reference error when the class is called after loading a new scene. Here are the C# classes defining the methods used in order to implement the functionality and screes snippets of my hierarchy in Unity 2019.4.1f1. I'm also attaching a short youtube video to show you that the score does work in the first scene, however it does not work in any other scene after. I do know that I'm destroying the Text UI at the beginning of every scene if there are multiple. What I do not understand is why the Text UI nested under the Scoreboard Canvas is not finding it's reference on Awake() for every instance created and why it's being called null. I truly appreciate anyone help!
Here are the screen snippets and videos in this order:
- Youtube video of bug
- Hierarchy of Scoreboard Canvas
- Hierarchy of Score Text
- Scoreboard singleton class (Attached to Scoreboard Canvas)/ ScoreText class (Attached to ScoreText UI)
- Implementation of classes used to add score upon completion of level in CollisionHandler class
Hierarchy of Scoreboard Canvas
CollisionHandler class used for implementation
If these don't help, here is the github link to see the project code:
...ANSWER
Answered 2020-Oct-01 at 22:52Store your score in a monobehavior that calls DontDestroyOnLoad(this.gameObject);
This will preserve that object between scene changes. https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install 3_Project_Boost
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page