我正在努力将UnityScript中的一个统一项目翻译成C#。我已经翻译了这个项目的大部分内容,但我遇到了一些问题:
characterController = GetComponent(CharacterController);抛出错误:
'UnityEngine.CharacterController' is a type but is used as a variable.
The overloaded method that best suits 'UnityEngine.Component.GetComponent (string)'
has invalid arguments第二个错误是:
GetComponent.<Animation>().Stop();抛出错误:
Only a subpoena, call, increment, and decrement, and an expectation of new object expressions
can be used as instruction.因此,这只是与GetComponent链接的错误,但在UnityScript中,它运行得很好。如何在C#中处理这个问题?
发布于 2015-09-17 14:25:06
characterController = GetComponent(CharacterController);应该在C#中使用通用版本调用:
characterController = GetComponent<CharacterController>();关于另一行,中间有一个额外的点。应:
GetComponent<Animation>().Stop();(不确定是否还必须指定要停止的特定动画的名称)。
https://stackoverflow.com/questions/32631996
复制相似问题