所以当我触摸一个硬币(Sprite,它是一个2D游戏)时,我正试图这样做它会被破坏并且我得到一个点,但问题是,它说得分在当前上下文中不存在。
UNITY ERROR: (Assets / _SCRIPTS / TextScore.cs(11,61):错误CS0103:当前上下文中不存在“得分”这个名称)
CODE:
using UnityEngine;
using System.Collections;
using UnityEngine.SocialPlatforms.Impl;
using UnityEngine.UI;
using System.Security.Cryptography.X509Certificates;
public class CodeSystem : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
int score = 0;
void OnCollisionEnter ( Collider other )
{
Debug.Log("Picked up coin!");
if (tag == "Coin")
{
Debug.Log("Added score!");
score = score + 1;
}
}
}