public void FinishUpdateMesh() { if (!is_job_valid) { return; } CompleteJob(); var a_out_poices = out_poices.AsArray(); var a_out_uv0 = out_uv0.AsArray(); var a_out_uv1 = out_uv1.AsArray(); var a_out_colors = out_colors.AsArray(); var a_out_indices = out_indices.AsArray(); int count = indeices_offset.Length; for (int i = 0; i < count; ++i) { var info = indeices_offset[i]; HUDGroup group = null; if (!building_group.TryGetValue(info.group, out group)) { continue; } var mesh = group.mesh; if (mesh == null) { // 说明group 被销毁或隐藏了 continue; } int out_quad_count = info.length; var mesh_info = group.mesh_info; // 检查下大小 if (out_quad_count > mesh_info.quad_count) { mesh_info.Resize(out_quad_count); } int v_count = out_quad_count * 4; int i_count = out_quad_count * 6; mesh.Clear(); #if UNITY_2019_3_OR_NEWER mesh.SetVertices(a_out_poices, info.v_index, v_count); mesh.SetUVs(0, a_out_uv0, info.v_index, v_count); mesh.SetUVs(1, a_out_uv1, info.v_index, v_count); mesh.SetColors(a_out_colors, info.v_index, v_count); mesh.SetIndices(a_out_indices, info.i_index, i_count, MeshTopology.Triangles, 0); #else NativeArray <Vector3> .Copy(a_out_poices, info.v_index, mesh_info.poices, 0, v_count); NativeArray <Vector2> .Copy(a_out_uv0, info.v_index, mesh_info.uv0, 0, v_count); NativeArray <Vector2> .Copy(a_out_uv1, info.v_index, mesh_info.uv1, 0, v_count); NativeArray <Color32> .Copy(a_out_colors, info.v_index, mesh_info.colors, 0, v_count); NativeArray <int> .Copy(a_out_indices, info.i_index, mesh_info.indices, 0, i_count); int index_length = mesh_info.indices.Length; for (int t = i_count; t < index_length; ++t) { mesh_info.indices[t] = 0; } mesh.vertices = mesh_info.poices; mesh.uv = mesh_info.uv0; mesh.uv2 = mesh_info.uv1; mesh.colors32 = mesh_info.colors; mesh.triangles = mesh_info.indices; #endif } }