目前正在开发插件并且现在卡住了。尝试搜索,但不知道该寻找什么,帮助..
我一切正常,直到我决定使用couroutines延迟。我需要将temp传递给另一个脚本。寻找//错误。由于
第一个脚本:
void Start()
{
skinnedMeshRenderer = GetComponent();
Speakers speakers = new Speakers();
SwaitTime = speakers.waitTime;
StalkSpeed = speakers.talkSpeed;
}
public void click()
{
foreach (Speakers i in speakerList)
{
string[] temp = split(i);
//ERROR
newLetterCombo = gameObject.AddComponent(); //able to access couroutine in 2nd script but does not pass temp argument like below.
//letterCombo newLetterCombo = new letterCombo(temp); [worked earlier but does not access couroutine, also puts up monobehavior new keyword not allowed]
newLetterCombo.switchStarter();
}
}
第二个脚本:
public string[] letters;
public letterCombo(string[] _letters)
{
letters = _letters;
}
public void switchStarter()
{
StartCoroutine(comboswitch());
}
private IEnumerator comboswitch()
{
foreach (string combo in letters)
{
switch (combo)
{
case "AA":
print("AA");
yield return new WaitForSeconds(2);
break;
[/code]
答案 0 :(得分:0)
致电
newLetterCombo.switchStarter(temp);
将其他功能更改为
public void switchStarter(string[] temp)
{
StartCoroutine(comboswitch(temp));
}
private IEnumerator comboswitch(string[] temp)
{
//...
}