Question by
DamienBloomie · Jul 22, 2017 at 08:24 PM ·
scene load
How can I get score from another scene to Game Over scene?
Hello people. I need to get player's score to another scene when game is over.I try to figure out about PDontDestroyOnLoad and PlayerPref system but my brain has explode. So, can you widely explain to me which code should I write to where?
These are my code block;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MoveBtch : MonoBehaviour {
public float movefast;
public float moveup;
public int puan;
// Use this for initialization
void Start () {
Time.timeScale = 1;
puan = 0;
}
// Update is called once per frame
void Update () {
transform.Translate (Vector3.forward * movefast * Time.deltaTime);
if (Input.GetKeyDown(KeyCode.Space)) {
GetComponent<Rigidbody> ().AddForce (Vector3.up * moveup);
}
}
void OnTriggerEnter(Collider tuche){
if (tuche.gameObject.tag=="Tetik") {
tuche.gameObject.transform.parent.root.gameObject.GetComponent<Loop> ().touch = true;
puan++;
}
if (tuche.gameObject.tag=="Wop") {
tuche.gameObject.transform.parent.root.gameObject.GetComponent<Loop2> ().touch2 = true;
}
}
void OnCollisionEnter (Collision tuche){
if (tuche.gameObject.tag=="Engel") {
GeymOvir ();
}
}
void GeymOvir(){
Time.timeScale = 0;
SceneManager.LoadScene ("Pause");
//The Pause scene is another scene which I try to read my score from first scene. Please help me out here.
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612130905im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I fix the Game Camera? 1 Answer
switching scenes take a long time 0 Answers
Unexpected duplication of scene 1 Answer
Spawning stops after second scene load 2 Answers
Best way to play an animation/scene inside a scene? 0 Answers