简体   繁体   English

用于 UnityEngine 的 Visual Studio Intellisense 无法正常工作

[英]Visual Studio Intellisense for UnityEngine not working

I am trying to write a script for Unity in C#.我正在尝试在 C# 中为 Unity 编写脚本。 I created the script and then I opened it.我创建了脚本,然后打开了它。 When I typed in Ge , I don't get Unity methods (I only see GetHashCode and GetType ).当我输入Ge时,我没有得到 Unity 方法(我只看到GetHashCodeGetType )。 I am looking for GetComponent .我正在寻找GetComponent I tried writing the script (from a tutorial) and it works fine in Unity, so only the intellisense is not working.我尝试编写脚本(来自教程),它在 Unity 中运行良好,所以只有智能感知不起作用。 It also doesn't work for new Vector3() .它也不适用于new Vector3()

I am using Visual Studio Community 2019 (v 16.5.2).我正在使用 Visual Studio Community 2019 (v 16.5.2)。

The complete script is:完整的脚本是:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AddConstantVelocity : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        GetComponent<Rigidbody>().velocity = new Vector3(2, 10, -6);   
    }
}

You need to specify VS Code as the default editor.您需要将 VS Code 指定为默认编辑器。 Edit > Prefernces > External tools > External Script Editor编辑 > 首选项 > 外部工具 > 外部脚本编辑器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM