0

I have a quiz game and I want to reset the score ,I created many score panels ,scores and gameinformation ( each one for add up to the score when u click next scene) I don't know how to create this index for reseting the score to 0 when you click button "BACK" ( to go to the home page) or when you start again the same quiz to erase the score from the last one . Score reset script this is a game manager I found but I don't know how to adapt to my problem

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ResetButton : MonoBehaviour
{
    public static ResetButton Instance;
    public bool isGameOver = false;
    public Score score;
 
    public Text scoreText;
    public Button yourButton;
    internal static object instance;

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }

    // Start is called before the first frame update
    void Start()
    {
        Button btn = yourButton.GetComponent<Button>();
        btn.onClick.AddListener(TaskOnClick);

    }

    public void TaskOnClick()
    {
        ScorePanelUpdater.Score = 0;
    }

    // Update is called once per frame
    void Update()
    {
        if (isGameOver && Input.GetMouseButtonDown(0))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

        }
       
    }

}
miha281
  • 31
  • 4

0 Answers0