Trying to change this variable from javascript to c#. I’m getting an error saying
“The contextual keyword `var’ may only appear within a local variable declaration”
static var PlayerCoin = 0;
rest of script is as follows
using UnityEngine;
using System.Collections;
public class CollectCoin : MonoBehaviour {
static var PlayerCoin = 0;
public GUISkin CoinDisplay;
public Rect CoinRect;
void OnTriggerEnter2D(Collider2D coin)
{
if(coin.tag == "Coin")
{
PlayerCoin++;
print(PlayerCoin);
Destroy(coin.gameObject);
}
}
void OnGUI()
{
GUI.skin = CoinDisplay;
GUI.Label(CoinRect, PlayerCoin, GUI.skin.GetStyle("Coin"));
}
}