2024-05-02 12:57:13 +01:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2024-06-13 01:52:43 +01:00
|
|
|
//* General Comments or Finished Tasks
|
|
|
|
//TODO Tasks left to be done for game
|
|
|
|
//! Bugs or Issues
|
|
|
|
//? Questions or Suggestions
|
|
|
|
|
2024-05-02 12:57:13 +01:00
|
|
|
public class MeshCombiner : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private List<MeshFilter> sourceMeshFilters;
|
|
|
|
[SerializeField] private MeshFilter targetMeshFilter;
|
|
|
|
|
|
|
|
[ContextMenu("Combine Meshes")]
|
|
|
|
private void CombineMeshes()
|
|
|
|
{
|
|
|
|
var combine = new CombineInstance[sourceMeshFilters.Count];
|
|
|
|
|
|
|
|
for (var i = 0; i < sourceMeshFilters.Count; i++)
|
|
|
|
{
|
|
|
|
combine[i].mesh = sourceMeshFilters[i].sharedMesh;
|
|
|
|
combine[i].transform = sourceMeshFilters[i].transform.localToWorldMatrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
var mesh = new Mesh();
|
|
|
|
mesh.CombineMeshes(combine);
|
|
|
|
targetMeshFilter.mesh = mesh;
|
|
|
|
}
|
|
|
|
}
|