[csharp] view plaincopyprint?在CODE上查看代码片派生到我的代码片 using UnityEngine; using System.Collections; public class CombineMeshes : MonoBehaviour { void Start() { MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>(); CombineInstance[] combine = new CombineInstance[meshFilters.Length]; int i = 0; while (i < meshFilters.Length) { combine[i].mesh = meshFilters[i].sharedMesh; combine[i].transform = meshFilters[i].transform.localToWorldMatrix; meshFilters[i].gameObject.SetActive(false); i++; } transform.GetComponent<MeshFilter>().mesh = new Mesh(); transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine); transform.gameObject.SetActive(true); } } [csharp] view plaincopyprint?在CODE上查看代码片派生到我的代码片 using UnityEngine; using System.Collections; using UnityEditor; public class EditorTools : MonoBehaviour { [MenuItem("Tools/Save Combine Mesh")] public static void SaveMesh() { Mesh m = Selection.activeGameObject.GetComponent<MeshFilter>().sharedMesh; AssetDatabase.CreateAsset(m, "Assets/tmp/cmbMesh.asset"); AssetDatabase.SaveAssets(); } }