30 lines
859 B
C#
30 lines
859 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
//* General Comments or Finished Tasks
|
|
//TODO Tasks left to be done for game
|
|
//! Bugs or Issues
|
|
//? Questions or Suggestions
|
|
|
|
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;
|
|
}
|
|
} |