Hi people,
I was wondering if anyone had any idea how to keep a canvas displaying a value like a coin counter keeping your coins between levels. Mine reverts to 0 when I switch levels and only corrects after picking up another coin. I’ll put the script i’m using below.
Coin Manager:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class CoinManager : MonoBehaviour
{
public static CoinManager instance;
public TextMeshProUGUI text;
static int coincount;
// Start is called before the first frame update
void Start()
{
if (instance == null)
{
instance = this;
}
}
public void ChangeScore(int coinValue)
{
coincount += coinValue;
text.text = “X” + coincount.ToString();
}
}
Coin Item:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Coin : MonoBehaviour
{
public int coinValue = 1;
Please use codetags, seems like this forum has been lately polluted by post from people who don’t read the rules how to post messages… is there still some problem or did you solve it?
That not that type of tag. When you’re editing a reply, up on the edit format part you’ll see a bunch of things (like B for Bold, I for Italics, and so on), among these you’ll see Code: followed by an icon. Press that icon, and it pops up an interface to add in code snippets like this: