why my score is always 1 when i click left mouse button,why it isnt adding like 1+1+1+1+1…? How to fix it
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Informator : MonoBehaviour
{
private string _Name { get; set; }
private int _Score { get; set; }
public TMP_Text nameText;
public TMP_Text scoreText;
private void OnMouseDown()
{
ShowName();
ShowScore();
Destroy(gameObject);
}
void ShowName()
{
_Name = gameObject.name;
nameText.text = _Name;
}
void ShowScore()
{
_Score+=1;
scoreText.text = _Score.ToString();
}
}