Updates the model mesh vertex and index buffer data. Can be used only for virtual assets (see and ). Mesh data will be cached and uploaded to the GPU with a delay. The mesh vertices positions. Cannot be null. The mesh index buffer (clockwise triangles
(Float3[] vertices, int[] triangles, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null, Color32[] colors = null)
| 121 | /// <param name="uv">The texture coordinates (per vertex).</param> |
| 122 | /// <param name="colors">The vertex colors (per vertex).</param> |
| 123 | public void UpdateMesh(Float3[] vertices, int[] triangles, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null, Color32[] colors = null) |
| 124 | { |
| 125 | if (!ParentModel.IsVirtual) |
| 126 | throw new InvalidOperationException("Only virtual models can be updated at runtime."); |
| 127 | if (vertices == null) |
| 128 | throw new ArgumentNullException(nameof(vertices)); |
| 129 | if (triangles == null) |
| 130 | throw new ArgumentNullException(nameof(triangles)); |
| 131 | if (triangles.Length == 0 || triangles.Length % 3 != 0) |
| 132 | throw new ArgumentOutOfRangeException(nameof(triangles)); |
| 133 | if (normals != null && normals.Length != vertices.Length) |
| 134 | throw new ArgumentOutOfRangeException(nameof(normals)); |
| 135 | if (tangents != null && tangents.Length != vertices.Length) |
| 136 | throw new ArgumentOutOfRangeException(nameof(tangents)); |
| 137 | if (tangents != null && normals == null) |
| 138 | throw new ArgumentException("If you specify tangents then you need to also provide normals for the mesh."); |
| 139 | if (uv != null && uv.Length != vertices.Length) |
| 140 | throw new ArgumentOutOfRangeException(nameof(uv)); |
| 141 | if (colors != null && colors.Length != vertices.Length) |
| 142 | throw new ArgumentOutOfRangeException(nameof(colors)); |
| 143 | |
| 144 | if (Internal_UpdateMeshUInt(__unmanagedPtr, vertices.Length, triangles.Length / 3, vertices, triangles, normals, tangents, uv, colors)) |
| 145 | throw new Exception("Failed to update mesh data."); |
| 146 | } |
| 147 | |
| 148 | /// <summary> |
| 149 | /// Updates the model mesh vertex and index buffer data. |
nothing calls this directly
no test coverage detected