public class ScoreManager : MonoBehaviour {
public static Text ScoreText;
public static int Count = 0;
void Start () {
Count = 0;
TextPrint();
}
public static void TextPrint()
{
ScoreText.text = Count.ToString();
}
}
이게 Count값을 Text에 보내는 스크립트고
public class CoinCheck : MonoBehaviour {
public static bool CoinOn = false;
public GameObject CoinPrefab;
void Update () {
if (!CoinOn)
{
ScoreManager.Count += 1; <- 이부분 오류
ScoreManager.TextPrint(); <- 이부분 오류
CoinOn = true;
GameObject Coin = (GameObject)Instantiate(CoinPrefab,
new Vector3(Random.Range(-2f, 2f), Random.Range(-4.6f, 4.6f), 0f),
Quaternion.identity); // 랜덤한 위치로 코인 생성
}
}
}
이게 코인먹으면 Count값 올려주고 아까 text에 보내는 함수 호출시키는건데 유니티로 돌려보니깐 계속 오류가 뜨는데 뭐가 문제인가요ㅠㅠㅠ
저거 ScoreText는 참조 어떻게 한거임? static인데
아래 글 보니까 static 함수에서 쓰려고 바꾼 것 같은데 static 필드는 인스펙터창에서 참조 못함
제...발.. 해결책을 찾아줘....
해당 텍스트에 태그를 준다음에 웨이크 에서 참조를 시켜 ㅇㅇ