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. Are you missing a using directive or an assembly reference?
错误CS0246:找不到类型或命名空间名称“collider”。您是否缺少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.
如果你想在这里找到代码的透视图。
1 个解决方案
#1
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)
. Therefore I think the type is Collider
not collider
.
我注意到你在PasteBin解决方案中使用的是typeof(Collider)。因此我认为类型是碰撞器不碰撞。
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.
然后,您可以使用碰撞对象访问属性大小和中心。
#1
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)
. Therefore I think the type is Collider
not collider
.
我注意到你在PasteBin解决方案中使用的是typeof(Collider)。因此我认为类型是碰撞器不碰撞。
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.
然后,您可以使用碰撞对象访问属性大小和中心。