我不知道如何使用统一标准组件解决的错误



unity标准组件预先打包了Visual Studio上的错误,我试图学习,所以我尝试使用自动更正系统,并将其减少到我能做到的错误最少。

我确保我拥有最新的 Unity 和 VisualStudio 以及所有相关插件。

https://gist.github.com/EgoSphere001/288818beb7ad0d2db2bdda028508c76e

请再看看你的脚本

public class PlayerMovement : MonoBehaviour
{
public PlayerMovement()
{
}
}
public Rigidbody rb;
// Start is called before the first frame update
private void Start() => Debug.Log("Hello, World!");
// Update is called once per frame
private void Update()
{
}

您正在关闭PlayerMovement类...那么rbUpdate属于哪里?!你Start表达式正文还可以,但我建议坚持使用正常的方法声明。

此外,MonoBehaviors不能使用构造函数生成,因此public PlayerMovement(){也没有意义。


您的脚本可能如下所示

public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;
// Start is called before the first frame update
private void Start()
{
Debug.Log("Hello, World!");
}
// Update is called once per frame
private void Update()
{
}
}

另请注意:您应该删除任何空的 Unity 消息,如UpdateStart等,因为 Unity 无论如何都会调用它们,从而导致不必要的开销。

相关内容

最新更新