我使用 objImporter 它不是问题创建统一但我导入创建 3dmax 它是问题
I use objImporter it is not problem created unity but i import created 3dmax it is problem
我使用 objImporter,它不是创建 unity 的问题,但我导入创建的 3dmax 是问题
사용한 스크립트
https://wiki.unity3d.com/index.php/ObjImporter
出现这个错误
Mesh.vertices is too large. A mesh may not have more than 65000 vertices.
UnityEngine.Mesh:set_vertices(Vector3[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:52)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
Mesh.uv is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
UnityEngine.Mesh:set_uv(Vector2[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:53)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
Mesh.normals is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
UnityEngine.Mesh:set_normals(Vector3[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:54)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 166833, VertexCount: 0
UnityEngine.Mesh:set_triangles(Int32[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:55)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
问题是脚本使用了 16 位索引的网格,它只支持最大 2^16 个顶点大小的模型。然而,Unity 支持 32 位索引,最多支持 2^32 个顶点 = ~40 亿。您需要做的就是添加这一行:
mesh.indexFormat = Rendering.IndexFormat.UInt32;
在此之后:
Mesh mesh = new Mesh();
函数内部ImportFile
。
请注意,某些移动设备不支持 32 位索引。
https://docs.unity3d.com/ScriptReference/Mesh-indexFormat.html
我认为您的问题与模型大小有关,因为网格可能有超过 65000 个顶点。你应该读取 65000 个顶点的每一块并将它们放在一个网格中,然后将所有网格块收集在一个网格中,即共享网格,
我强烈推荐使用此资产 Simple .OBJ,它将节省您的时间
我使用 objImporter,它不是创建 unity 的问题,但我导入创建的 3dmax 是问题
사용한 스크립트 https://wiki.unity3d.com/index.php/ObjImporter
出现这个错误
Mesh.vertices is too large. A mesh may not have more than 65000 vertices.
UnityEngine.Mesh:set_vertices(Vector3[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:52)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
Mesh.uv is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
UnityEngine.Mesh:set_uv(Vector2[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:53)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
Mesh.normals is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
UnityEngine.Mesh:set_normals(Vector3[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:54)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 166833, VertexCount: 0
UnityEngine.Mesh:set_triangles(Int32[])
ObjImporter:ImportFile(String) (at Assets/MyAssets/Scripts/ObjImporter.cs:55)
UIManager:Load() (at Assets/MyAssets/Scripts/UIManager.cs:50)
UnityEngine.EventSystems.EventSystem:Update()
问题是脚本使用了 16 位索引的网格,它只支持最大 2^16 个顶点大小的模型。然而,Unity 支持 32 位索引,最多支持 2^32 个顶点 = ~40 亿。您需要做的就是添加这一行:
mesh.indexFormat = Rendering.IndexFormat.UInt32;
在此之后:
Mesh mesh = new Mesh();
函数内部ImportFile
。
请注意,某些移动设备不支持 32 位索引。
https://docs.unity3d.com/ScriptReference/Mesh-indexFormat.html
我认为您的问题与模型大小有关,因为网格可能有超过 65000 个顶点。你应该读取 65000 个顶点的每一块并将它们放在一个网格中,然后将所有网格块收集在一个网格中,即共享网格,
我强烈推荐使用此资产 Simple .OBJ,它将节省您的时间