• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Ilies_Ioan · Apr 22, 2020 at 09:43 AM · scene-loadinglevel loadpop-up

Hello , I will like a little bit of help regarding a game that I create.

Idea is that I am pretty new in programming just as a hobby and my game have scrolling background. I have different scenes that I will like to add to my game play as If the player make a 50 score to create a pop up with a button that will launch the new scene but keeping also the score from the previous one. Also when my hero dies I will like to start the game on click with the initial scene and score to be again 0. I am loosing it and cannot do this to work proper.

-using UnityEngine;

-using System.Collections;

-using UnityEngine.UI;

-using UnityEngine.SceneManagement;

 public class GameControl : MonoBehaviour

{

 public static GameControl instance;            
 public Text scoreText;
 public Text highScoretext;                                                
 public GameObject gameOvertext;                                                
 private int score = 0;
 public string CongratulationsMenu;
 public bool gameOver = false;                                                
 public float scrollSpeed = -1.5f;

 void Start()
 {
     highScoretext.text = "High score: " + ((int)PlayerPrefs.GetFloat("HighScore")).ToString();
   //  score = PlayerPrefs.GetInt("Score");
 }

 void Awake()
 {
     
     if (instance == null)
                   
          instance = this;
      else if (instance != this)
       
         Destroy(gameObject);
 }
     
 void Update()
 {
     if (gameOver == true && Input.GetMouseButtonDown (0))
     {
      SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
     if(score >= 3)
    {
         NewWorld();
     }
   //  scoreText.text = "Score: " + score; PlayerPrefs.SetInt("Score", score);
       }
   
 public void HeroScored()
 {
     //The bird can't score if the game is over.
     if (gameOver)
         return;
     //If the game is not over, increase the score...
     score++;
     //...and adjust the score text.
     scoreText.text = "Score: " + score.ToString();
        }
          public void HeroDied()
     {
     //Activate the game over text.
     gameOvertext.SetActive(true);
     //Set the game to be over.
     gameOver = true;
     if (PlayerPrefs.GetFloat("HighScore") < score)
     PlayerPrefs.SetFloat("HighScore", score);
        
      }
 public void NewWorld()
 {      
     Time.timeScale = 1f;
   //  PlayerPrefs.SetFloat("Score", score);
     PlayerPrefs.SetFloat("HighScore", score);
    //scoreText.text = "Score: " + score; PlayerPrefs.SetInt("Score", score);
     SceneManager.LoadScene(CongratulationsMenu);
  
 }

}

the commented code is some of what i have worked with, Could some of you that have experience may help me ? Thank you in advance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

200 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Entrances to levels 0 Answers

Load level once 0 Answers

Scene is loading in Game Mode, but not in the build. Why? 2 Answers

Level Loads In Editor But Not Loads On Android 1 Answer

How to passing levels automatically in games? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges