【发布时间】:2017-10-05 14:15:11
【问题描述】:
我有 2 个脚本:控制台和测试。我想从测试脚本中调用“appendLogLine”函数,但无法正常工作。
控制台.cs:
public class ConsoleController
{
public void appendLogLine(string line)
{
if (line == "Unable to process command ''")
return;
Debug.Log(line);
if (scrollback.Count >= ConsoleController.scrollbackSize)
{
scrollback.Dequeue();
}
scrollback.Enqueue(line);
log = scrollback.ToArray();
if (logChanged != null)
{
logChanged(log);
}
}
}
Test.cs:
public GameObject ConsoleObject;
public void CallLog()
{
ConsoleObject.GetComponent<ConsoleController>.appendLogLine ("Test123");
}
我收到错误:“错误 CS0119:表达式表示 method group', where avariable',value' ortype' 是预期的”
【问题讨论】:
-
ConsoleObject.GetComponent<ConsoleController>().appendLogLine ("Test123");