通过加载prefab想要获取meshFilter上的mesh组件是失败的,在实例化后可以获取,但是这种做法毫无疑问是愚蠢的,目前我就用这种方法
//创建一个小球,并获取小球上的mesh组件哦
this.transform.GetComponent<MeshFilter>().mesh = GameObject.CreatePrimitive(PrimitiveType.Sphere).GetComponent<MeshFilter>().mesh;
这是我获取一组26个字母中mesh的方法
m_letterMeshFilterPathStr = "Common/BigLetter/";
m_letterMeshFilterLength = 26;//26个字母和一个空的材质
m_allMeshFilter = new Mesh[m_letterMeshFilterLength];
//获得所有字母的meshFilter,从而得到他们的mesh
for (char i = 'A'; i <= 'Z'; i++)
{
GameObject go = GameObject.Instantiate(Resources.Load(m_letterMeshFilterPathStr + i) as GameObject);
m_allMeshFilter[i - 'A'] = go.GetComponent<MeshFilter>().mesh;
Destroy(go);
}