I want to add a score feature to my game, my game is clicking buttons right after it disappear but when i click the button my expection is the score text will show number instead it generate random number, How can i fix this Help
this is my scripts
ScoreScripts
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScoreScript : MonoBehaviour
{
public GameObject btn;
public Text ScoreText;
public int ScoreAdd;
public void Score()
{
ScoreText.text = ScoreAdd.ToString();
ScoreAdd++;
}
}
Button Script
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class ButtonScript : MonoBehaviour
{
public GameObject btn;
public int destroyTime;
void Update()
{
btn.GetComponent<Button> ().onClick.AddListener(IsClicked);
}
void IsClicked()
{
Destroy (this.btn);
FindObjectOfType<ScoreScript> ().Score();
}
void Start()
{
Invoke ("nextScene", destroyTime);
}
void nextScene()
{
SceneManager.LoadScene ("GameOver");
}
}