Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

restart a scene to have another round

Discussion in 'Scripting' started by jasmindelacruz, Jul 20, 2014.

  1. jasmindelacruz

    jasmindelacruz

    Joined:
    Jun 25, 2014
    Posts:
    30
    restart a scene and proceed to another round but only the score will not restart...though i have 3 rounds...and after the 3rd round it will declare now the winner..
     
  2. domkia

    domkia

    Joined:
    Aug 19, 2012
    Posts:
    99
    You can store rounds in PlayerPrefs and just load the same scene again with Application.LoadLevel(Application.loadedLevel)
     
  3. jasmindelacruz

    jasmindelacruz

    Joined:
    Jun 25, 2014
    Posts:
    30
    how to insert it here...sorry im a beginner...please help...

    Code (CSharp):
    1.  
    2.  
    3.  
    4. using UnityEngine;
    5. using System.Collections;
    6.  
    7. public class TriggerIt : MonoBehaviour {
    8.     public static int scorePlayer1 = 0;
    9.     public GUIText scorePlayer1Text;
    10.  
    11.  
    12.  
    13.  
    14.     // Use this for initialization
    15.     void OnTriggerEnter2D(Collider2D other)
    16.     {
    17.         scorePlayer1++;
    18.         Destroy (gameObject);
    19.         scorePlayer1Text.text = scorePlayer1.ToString();
    20.  
    21.     }
    22. }