0
我有2個腳本:控制檯和測試。我想從測試腳本調用「appendLogLine」函數,但無法使其工作。Unity從其他腳本調用類功能
Console.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 a
變量 'value' or
型' 預期」
'ConsoleObject.GetComponent()appendLogLine( 「Test123」);' –
zwcloud