调用启动协程时 IEnumerator 未触发

问题描述 投票:0回答:0

所以我的代码应该在 3.5 秒后将其打印到控制台,但由于某种原因它从未发生。

我不知道该尝试什么。

这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Talking : MonoBehaviour
{
    public TextMeshPro t;
    public Component talk;

    void Start()
    {
        GetComponent<TextMeshPro>().enableWordWrapping = false;
        StartCoroutine("Speech");
    }

    public IEnumerator Speech()
    {
        yield return new WaitForSeconds(3.5f);
        Debug.Log("yay my code works");
    }
}
c# unity-game-engine ienumerator
© www.soinside.com 2019 - 2024. All rights reserved.