Unityのタイピングゲームでスコア表示させたい
Unityでタイピングゲームを作っているのですがスコア表示のコードを打って表示させるobjectにスクリプトを入れようとしたところ以下のメッセージが出ました
ソース
タイピング判定
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
//using System.Collections.Generic;
public class Type : MonoBehaviour
{
public TextMesh ScoreTextMesh; public TextMesh stringTextMesh; public TextMesh alphabetTextMesh; public Dictionary dictionary; public static int score = 0; //public Score score; TypingSystem ts; // Use this for initialization void Start() { ts = new TypingSystem(); ts.SetInputString(dictionary.GetRandomWord()); //point = point + 100; UpdateText(); } // Update is called once per frame void Update() { string[] keys = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
"u", "v", "w", "x", "y", "z", "-",};
foreach (string key in keys)
{
if (Input.GetKeyDown(key))
{
if (ts.InputKey(key) == 1)
{
UpdateText();
//point = point + 100;
}
break;
}
}
if (ts.isEnded())
{
ScoreScript.hantei = 1;
ts.SetInputString(dictionary.GetRandomWord());
UpdateText();
//scoreGUI.SendMessage ("AddPoint",point * 1);
//point = point + 100;
}
//point = point + 100;
}
void UpdateText() { stringTextMesh.text = "<color=red>" + ts.GetInputedString() + "</color>" + ts.GetRestString(); alphabetTextMesh.text = "<color=red>" + ts.GetInputedKey() + "</color>" + ts.GetRestKey(); }
}
スコア表示
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ScoreScript : MonoBehaviour
{
public Text scoreText;
public static int score = 0;
public static int hantei;
void OnGUI()
{
GUI.Label(new Rect(100, 15, 500, 300), "SCORE:" + score);
}
void Start()
{
//GetComponent<Text>().text = "Score: " + score.ToString(); } void Update() { if (hantei == 1) { score = score + 10; hantei = 0; } //GetComponent<Text>().text = "Score: " + score.ToString(); }
}
C#
試したこと
class名とobject名が違うためなのかと思い変えたのですがダメでした
補足情報
version 2018.2.11f1 Personal
テキストエディタvisual studio
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。