我试图遵循本教程,该教程最初是为UnityScript编写的,但使用Boo:http://docs.unity3d.com/Manual/Example-CreatingaBillboardPlane.html
以下是我尝试过的:
import UnityEngine
class CreateMesh (MonoBehaviour):
def Start ():
meshFilter = GetComponent(MeshFilter)
mesh = Mesh()
mesh.vertices = [Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(1, 1, 0)]
mesh.triangles = [0, 2, 1, 2, 3, 1]
mesh.normals = [-Vector3.forward, -Vector3.forward, -Vector3.forward, -Vector3.forward]
meshFilter.mesh = mesh
def Update ():
pass不幸的是,我列出的每一个文字都带来了问题:
无法将“Boo.Lang.List”转换为“(UnityEngine.Vector3)” 无法将“Boo.Lang.List”转换为“(Int)” 无法将“Boo.Lang.List”转换为“(UnityEngine.Vector3)”
这有点令人失望--我原以为Boo能够推断出我的列表的类型,因为里面的所有元素都是同一类型的。无论如何,我认为所需要的只是发表某种形式的声明。我看过其他几个关于团结的Boo示例,但是它们似乎都没有像我想要的那样利用列表。
我仔细研究了一下,发现我可以转换成这样的类型列表:
[...] as List[of type]所以我就这样做了:
mesh.triangles = [0, 2, 1, 2, 3, 1] as List[of int]但这仍然不起作用-它只是将我的错误消息更改为:
无法将'Boo.Lang.Listof int‘转换为'(int)’。
我不知道(int)是什么意思--我原以为那是一个只由int组成的List,但我似乎错了。
发布于 2014-10-10 18:41:56
关键点: Mesh类需要数组,而不是列表。这两种类型非常相似,但并不完全相同。
Type C# Boo
-----------------------------------------------
List of integers List<int> List[of int]
Array of integers int[] (int)
Dictionary ??? Dictionary[of key, value]这一行创建了一个ints列表:
mesh.triangles = [0, 2, 1, 2, 3, 1]相对于一个ints数组:
mesh.triangles = (0, 2, 1, 2, 3, 1)注意,我们将[]大括号替换为()父母。
https://stackoverflow.com/questions/26303184
复制相似问题