【发布时间】:2020-04-04 00:33:46
【问题描述】:
我正在尝试用 C# 为 Unity 编写脚本。我创建了脚本,然后打开了它。当我输入 Ge 时,我没有得到 Unity 方法(我只看到 GetHashCode 和 GetType)。我正在寻找GetComponent。我尝试编写脚本(来自教程),它在 Unity 中运行良好,所以只有智能感知不起作用。它也不适用于new Vector3()。
我正在使用 Visual Studio Community 2019 (v 16.5.2)。
完整的脚本是:
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);
}
}
【问题讨论】:
标签: c# visual-studio unity3d