简体   繁体   English

找不到类型或命名空间名称

[英]The type or namespace name not found

I have a code write in C# which I use in unity5 but because was for a old version of unity I have a little problem. 我在C#中编写了一个代码,我在unity5中使用但是因为对于旧版本的统一我有一点问题。

error CS0246: The type or namespace name `collider' could not be found. 错误CS0246:找不到类型或命名空间名称“collider”。 Are you missing a using directive or an assembly reference? 您是否缺少using指令或程序集引用?

Code is 代码是

Vector3 worldPosition = GetComponent<collider>().bounds.center + Vector3.up * collider.bounds.size.y * 0.5f;

If you want a perspective of code here . 如果你想在这里找到代码的透视图。

The error is telling you that you do not have a type or namespace called collider within the solution. 该错误告诉您在解决方案中没有名为collider的类型或命名空间。

I noticed from your PasteBin solution you are using typeof(Collider) . 我注意到你在PasteBin解决方案中使用的是typeof(Collider) Therefore I think the type is Collider not collider . 因此我认为类型是Collidercollider

Also you may need an instance of this object in order to use the properties: 此外,您可能需要此对象的实例才能使用以下属性:

Collider collider = GetComponent<Collider>();

Then you can use the collider object to access the properties size and center. 然后,您可以使用collider对象访问属性大小和中心。

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

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