using System; using System.Collections; using System.Collections.Generic; using MeshCombineStudio; using NGS.AdvancedCullingSystem.Dynamic; using UnityEngine; using UnityEngine.Events; #if UNITY_EDITOR using UnityEditor; #endif namespace BITKit.OpenWorld { public class OpenWorldCombiner : MonoBehaviour { [SerializeField] private MeshCombiner meshCombiner; [SerializeField] private UnityEvent onCombiningReady; [SerializeField] private bool allowCullingSource = true; private void Start() { meshCombiner.onCombiningReady +=x=> onCombiningReady.Invoke(); meshCombiner.onCombiningReady += AddCullingSource; } private void AddCullingSource(MeshCombiner meshcombiner) { if (allowCullingSource) AddCullingSource(); } [BIT] private void AddCullingSource() { var reportBuilder = new System.Text.StringBuilder(); var renderers = meshCombiner.GetComponentsInChildren(true); reportBuilder.AppendLine($"找到{renderers.Length}个Renderer"); foreach (var x in renderers) { if (x.GetComponent()) continue; x.gameObject.AddComponent(); reportBuilder.AppendLine($"为{x.name}添加了DC_SourceSettings"); } Debug.Log(reportBuilder.ToString()); } } }