public class SceneLoader : MonoBehaviour
{
//Scene1
void Start()
{
Debug.Log("Scene1 started");
if (!PlayerPrefs.HasKey("Score"))
{
PlayerPrefs.SetInt("Score", 1);
}
Debug.Log(PlayerPrefs.GetInt("Score"));
}
void Update()
{
if(Input.anyKey)
{
SceneManager.LoadScene(1);
}
}
}
---------------------------------------------------
Scene2
public class SceneLoader2 : MonoBehaviour
{
void Start()
{
Debug.Log("Scene2 start");
int score = PlayerPrefs.GetInt("Score");
score++;
PlayerPrefs.SetInt("Score", score);
Debug.Log(score);
}
void Update()
{
if (Input.anyKey)
{
SceneManager.LoadScene(0);
}
}
}