Score to Zero only on Game Start...
Hi... I need the Score to go back to Zero on Game Start... All of my scenes (Intro_Canvas, Game_Canvas, GameOver_Canvas) are located in 1 scene file... I have tried:
if(Application.LoadedLevelName =="OutsideScene")...
and it works... Score goes back to Zero ... But... I am wondering if there is any way to return the score to zero within the scene file... Without going to an outside scene... Example... Is there a way to tell the score to go back to Zero only when the Game_Canvas Awakes or Starts... ? I ask this because when I use the following lines of script in my ScoreManager:
PlayerPrefs.SetInt("Score", 0); Score = 0;
...the score goes back Zero in the Game, but also goes back to zero in the GameOver_Canvas, which is no good... and also effects my HighScore chart... Is there a way to return the score to zero within the scene file(ONLY when the Game_Canvas awakes) without effecting the GameOver _Canvas? Fbm...
Answer by fredmiller12345 · May 13, 2017 at 03:43 PM
Here is my ScoreManager...
public class ScoreManager : MonoBehaviour {
 public static int Score;
 public int score;
 void Awake()
 {
     if (Application.loadedLevelName == "OutsideScene")
     {
         PlayerPrefs.SetInt("Score", 0);
         Score = 0;
     }
 }
 public int _score
 {
     get
     {
         return Score;
     }
     set
     {
         Score = value;
     }
 }
 internal static void UpdateScoreText(int v)
 {
     throw new NotImplementedException();
 }
 void FixedUpdate()
 {
     Text textcomponent;
     textcomponent = GetComponent<Text>();
     if (textcomponent != null)
         textcomponent.text = " " + _score.ToString();
     PlayerPrefs.SetInt("finalScore", Score);
 }
}
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                