Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Diplay player final score in new scene in unity

public class PlayerScore : MonoBehaviour 
{

    public Transform player;
    public Text scoreText; 

    // Update is called once per frame
    void Update() 
    {
        scoreText.text = player.position.y.ToString("0"); 
        PlayerPrefs.SetInt("CurrentScore", player.position.y);
    }
}
Comment

Diplay player final score in new scene in unity

public class EndMenu: MonoBehaviour 
{

    public Text scoreText;
    public Transform player;
    public static bool GameEnds = false;
    public GameObject endMenuUI;

    void OnCollisionEnter2D(Collision2D exampleCol) 
    {
        if(exampleCol.collider.tag == "Obstacle")
        {
            endMenuUI.SetActive(true);
            Time.timeScale = 0.0001f;
            GameEnds = true;
        }
    }

    public void Retry()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }

    public void BackToMenu()
    {
        SceneManager.LoadScene("Menu");
    }

    public void Quit()
    {
        Debug.Log("Quitting game...");
        Application.Quit();
    }

    // Update is called once per frame
    void Update()
    {
        scoreText.text = PlayerPrefs.GetInt("Score",0);
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: VideoPlayer.isPlaying 
Csharp :: ExecuteResultAsync ActionContext statuscode 
Csharp :: get all viewsheet revit api 
Csharp :: unity call function after delay 
Csharp :: c# convert linq jValue to int 
Csharp :: unity 3d animator live link 
Csharp :: .Net Entity Framework Reseed SQL Server Table ID Column 
Csharp :: auto scroll infinite scroller unity 
Csharp :: asp net identity login failed for user 
Csharp :: vb.net convert int32 into boolean array stack overflow 
Csharp :: DrawImage resize to target size c# 
Csharp :: 110771 
Csharp :: IOS app crashing on ios 15 unity 
Csharp :: netmath hack console 
Csharp :: Delegate parameter no return 
Csharp :: touch screen to world point 
Csharp :: check if app have administrator rights c# 
Csharp :: c# custom comment tags 
Csharp :: slider script unity 
Csharp :: Close Form After fixed time 
Csharp :: c# crud observablecollection -mvvm 
Csharp :: c# get executing method name 
Csharp :: binary search tree c# stackoverflow 
Csharp :: ignore warning openxml 
Csharp :: create shortcut C# WPF 
Csharp :: unity use of possibly unassigned field struct 
Csharp :: unity3d spin wheel 
Csharp :: struct 
Csharp :: upcasting and downcasting in c# 
Csharp :: c# mail retrieve library 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =