From f6fd7efeb3036f5288459ae7910938e94b741994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Hodossy?= Date: Tue, 1 Nov 2022 22:21:30 +0000 Subject: [PATCH] Add UVs to newly created geom meshes --- unity/Runtime/Components/Shapes/MjMeshFilter.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unity/Runtime/Components/Shapes/MjMeshFilter.cs b/unity/Runtime/Components/Shapes/MjMeshFilter.cs index dd238ba4..f97902fa 100644 --- a/unity/Runtime/Components/Shapes/MjMeshFilter.cs +++ b/unity/Runtime/Components/Shapes/MjMeshFilter.cs @@ -55,6 +55,12 @@ public class MjMeshFilter : MonoBehaviour { _meshFilter.sharedMesh = mesh; mesh.vertices = meshData.Item1; mesh.triangles = meshData.Item2; + Vector2[] uvs = new Vector2[mesh.vertices.Length]; + for (int i = 0; i < uvs.Length; i++){ + uvs[i] = new Vector2(mesh.vertices[i].x, mesh.vertices[i].z); + } + mesh.uv = uvs; + mesh.RecalculateNormals(); mesh.RecalculateTangents(); }