I have some problem , I copied Unity Projects: 2D Platformer game, and created twice as a second level .and I tried to move second level but I could do save the score . How can I do that?
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour
{
public int score = 0; // The player’s score.
private PlayerControl playerControl; // Reference to the player control script.
private int previousScore = 0; // The score in the previous frame.
// private float _score = 0;
void Awake ()
{
// Setting up the reference.
playerControl = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();
//Write the score in the GUI text
//previousScore = _score;
DontDestroyOnLoad(gameObject);
}
void Update ()
{
// Set the score text.
guiText.text = "Score: " + score;
// If the score has changed...
if(previousScore != score)
// ... play a taunt.
playerControl.StartCoroutine(playerControl.Taunt());
if (score >= 500) {
// PlayerPrefs.SetInt("score", _score);
Application.LoadLevel("LEVELX");
}
// Set the previous score to this frame's score.
previousScore = score;
}
}