Unityについてです。
コルーチンが開始されないでエラーが出てしまいます。どうすればいいのでしょうか?
Coroutine 'HIHyouzi' couldn't be started!
UnityEngine.MonoBehaviour:StartCoroutine(String)
ITEMR:ITHIHyouzi() (at Assets/ITEMR.cs:24)
BattleManager:ITEMR1() (at Assets/BattleScene/Battle comand texture/BattleManager.cs:755)
ITEMR:OnMouseOver() (at Assets/ITEMR.cs:61)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
コルーチンを開始しようとするとこのエラー文が出ます。
コード
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ITEMR : MonoBehaviour
{
GameObject BattleManagger;
BattleManager script;
// Start is called before the first frame update
void Start()
{
transform.position = new Vector2(-5, 100);
BattleManagger = GameObject.Find("BattleManagger");
script = BattleManagger.GetComponent<BattleManager>();
}
// Update is called once per frame void Update() { } public void ITHIHyouzi() { StartCoroutine("HIHyouzi"); } public void ITHyouzi() { StartCoroutine("Hyouzi"); } IEnumerator Hyouzi() { transform.position = new Vector2(-5,6); for (float f = 0; f < 14; f++) { transform.Translate(new Vector2(0, -0.5f)); yield return new WaitForSeconds(0.02f); } } IEnumerator HiHyouzi() { transform.position = new Vector2(-5, -1); for (float f = 0; f < 14; f++) { transform.Translate(new Vector2(0, -0.5f)); yield return new WaitForSeconds(0.02f); } } private void OnMouseOver() { if (Input.GetMouseButtonDown(0)) { script.ITEMR1(); } }
}
BattleManagerのコード(一部)
public void ITEMR1()
{
ITEMNUM = 1;
ITEMRS.ITHIHyouzi();
}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。