我正在使用Unity制作我的第一个游戏,尝试在开场剪辑结束后加载第一关。不确定是否可以在视频片段结束后使脚本执行某些操作,因此我编写了如下代码:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class CutsceneEnd : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
StartCoroutine("wait");
}
IEnumerator wait()
{
yield return new WaitForSeconds(36);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
但问题不在于等待视频结束的方法,而在于加载的场景。我无法移动我的角色,因为脚本中的所有引用都为空。我不知道我做错了什么。