我有这段代码而且我一直收到错误消息
参数超出范围
我一直关注这个tutorial并且我一直在关注它。我回去检查了一切,但我仍然收到消息。
这是我的代码:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DialogSystem : MonoBehaviour {
public static DialogSystem Instance { get; set; }
public GameObject dialogPanel;
public string npcname;
public List<string> dialoglines = new List<string> ();
Button continueButton;
Text dialogText, nameText;
int dialogIndex;
// Use this for initialization
void Awake () {
continueButton = dialogPanel.transform.Find
("Continue").GetComponent<Button> ();
continueButton.onClick.AddListener (delegate { ContinueDialog(); });
dialogText = dialogPanel.transform.Find("Text").GetComponent<Text>();
nameText =
dialogPanel.transform.Find("Name").GetChild(0).GetComponent<Text>();
dialogPanel.SetActive(false);
if (Instance != null && Instance != this) {
Destroy (gameObject);
}
else
{
Instance = this;
}
}
public void addNewDialog(string[] lines, string npcname)
{
dialogIndex = 0;
dialoglines = new List<string>(lines.Length);
dialoglines.AddRange (lines);
this.npcname = npcname;
Debug.Log (dialoglines.Count);
CreatDialog ();
}
public void CreatDialog()
{
dialogText.text = dialoglines [dialogIndex];
nameText.text = npcname;
dialogPanel.SetActive (true);
}
public void ContinueDialog()
{
if (dialogIndex < dialoglines.Count - 1) {
dialogIndex++;
dialogText.text = dialoglines [dialogIndex];
}
else
{
dialogPanel.SetActive (false);
}
}
我不知道,我正在深入工作,而且我是一名新开发人员,我正在努力解决这个问题。任何帮助表示赞赏。