unity初心者です。3Dで作った的あてゲームにおいてPrefabを使って的を作成したのですがテキストがうまく接続できずスコアが加算されません
Prefabにする前はスコアは加算されていました
発生している問題・エラーメッセージ
エラーメッセージ Trying to Invoke method: mato.Generate couldn't be called. ### 該当のソースコード using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class target : MonoBehaviour { GameObject prefab; private Vector3 targetpos; public Text Scoretext; public static int score = 0; private void OnCollisionEnter(Collision collision) { score += 10; Scoretext.text = string.Format("Score:{0}",score); } public static int getscore() { return score; } void Start() { score = 0; } ///////////////////////////////////////////////////////////////////////////////////////////////// using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class matoGen : MonoBehaviour { public GameObject mato; int count = 0; int max = 99; // Start is called before the first frame update void Start() { InvokeRepeating("Generate", 1, 6); } // Update is called once per frame void Update() { } void Generate() { if (count == max) return; float x = Random.Range(-2.5f, 2.5f); float y = Random.Range(6f,9f); float z = 7; Vector3 position = new Vector3(x, y, z); Instantiate(mato, new Vector3(x,y,z), Quaternion.Euler(90,0,0)); count++; } } 上が的本体のスクリプトで下がジェネレーターのスクリプトです ```ここに言語名を入力 ソースコード C# ### 試したこと ### 補足情報(FW/ツールのバージョンなど) ここにより詳細な情報を記載してください。
ScoreTextをPrefab化した理由を教えてもらってもいいですか?
回答1件
あなたの回答
tips
プレビュー