unity, 获取mesh名称

正确的获取mesh名称的方法:

  MeshFilter meshFilter=node.GetComponent<MeshFilter>();
    string meshName=meshFilter.sharedMesh.name;

错误的获取mesh名称的方法:

  MeshFilter meshFilter=node.GetComponent<MeshFilter>();
    string meshName=meshFilter.mesh.name;

因为meshFilter.mesh会使unity创建新的mesh,而且新的mesh名称也变了,比如原来的mesh名叫“myMesh”,则使用meshFilter.mesh.name获得到得名称是"myMesh Instance"。

原文地址:https://www.cnblogs.com/wantnon/p/5224811.html