无法找到RayCastHit错误消息* Unity *

时间:2014-06-18 10:17:49

标签: c# scripting unity3d

我正在关注教程:https://www.youtube.com/watch?v=9Gx2tmhKq2g

并且在教程中,使用了数据类型RayCastHit,但是在MonoDevelop中,这个关键字没有为我突出显示,所以我认为它找不到...然后我收到错误消息'The type /找不到命名空间名称RayCastHit。'

我想知道我是否需要做一些特定的事来解决这个问题,或者这只是我另一个愚蠢的Unity错误:P

到目前为止我的脚本代码是:

using UnityEngine;
using System.Collections;

public class RayCast : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

    //if left mouse button clicked,
    // create ray cast from mouse clicked pos.

    Ray rayOrigin;
    RayCastHit hitInfo;

}

}

我可能在创建后将项目从一个文件夹移动到另一个文件夹,所以我不确定这是不是因为它混淆了...因为我使用专用文件夹将所有Unity项目放入...(文档/ UnityProjects / RayCastTutorial)其中RayCastTutorial是这个项目的名称。

感谢非常棒并帮助我:)

1 个答案:

答案 0 :(得分:3)

" c"在RaycastHit中需要小写,而不是大写。

因此,在Update函数结束时,请确保您的行符合:

RaycastHit hitInfo;