static private GameObject CreateMerged(string name, MeshFilter[] meshFilters, Material[] materials, int layer, bool receiveShadow, ShadowCastingMode shadowCasting) { GameObject go = new GameObject(name); go.layer = layer; var renderer = go.AddComponent <MeshRenderer>(); renderer.sharedMaterials = materials; renderer.receiveShadows = receiveShadow; renderer.shadowCastingMode = shadowCasting; Mesh mesh = new Mesh(); var combinationBuilder = new MeshCombinationBuilder(); combinationBuilder.Init(meshFilters); combinationBuilder.Start(); combinationBuilder.Complete(mesh); combinationBuilder.Dispose(); var meshFilter = go.AddComponent <MeshFilter>(); meshFilter.sharedMesh = mesh; return(go); }
protected JobHandle ScheduleCombineMeshes(NativeArray <DataInstance> instanceArray, TileTheme theme, JobHandle dependOn) { combinationBuilder = new MeshCombinationBuilder(); AddTemp(combinationBuilder); combinationBuilder.Init(instanceArray, theme); dependOn = combinationBuilder.Start(dependOn); return(dependOn); }
public void Init(NineScale nineScale, Vector3 targetSize) { nineScale.Recalculate(Vector3.zero, Quaternion.identity, targetSize); var meshParts = nineScale.GatherParts(); if (meshParts == null || meshParts.Length == 0) { Debug.LogError("couldn't gather nine scale parts for a mesh!"); return; } Mesh[] meshes = new Mesh[meshParts.Length]; Matrix4x4[] matrices = new Matrix4x4[meshParts.Length]; for (int i = 0; i < meshParts.Length; ++i) { meshes[i] = meshParts[i].Mesh; matrices[i] = meshParts[i].Matrix; } combinationBuilder.Init(meshes, matrices); Inited(); }