51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using MeshCombineStudio;
|
|
using NGS.AdvancedCullingSystem.Dynamic;
|
|
using UnityEngine;
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
#endif
|
|
namespace BITKit.OpenWorld
|
|
{
|
|
public class OpenWorldCombiner : MonoBehaviour
|
|
{
|
|
#if UNITY_EDITOR
|
|
[SerializeField] private MeshCombiner meshCombiner;
|
|
|
|
[BIT]
|
|
private void Combine()
|
|
{
|
|
if (meshCombiner.transform.childCount > 0)
|
|
{
|
|
if (EditorUtility.DisplayDialog("Warning","继续合并会丢失现有的Rig","OK,丢失已有Rig","取消,保留Rig") is false)
|
|
{
|
|
Debug.Log("用户取消了合并");
|
|
return;
|
|
}
|
|
}
|
|
meshCombiner.CombineAll();
|
|
#endif
|
|
}
|
|
|
|
[BIT]
|
|
private void AddCullingSource()
|
|
{
|
|
var reportBuilder = new System.Text.StringBuilder();
|
|
var renderers = meshCombiner.GetComponentsInChildren<MeshRenderer>(true);
|
|
reportBuilder.AppendLine($"找到{renderers.Length}个Renderer");
|
|
foreach (var x in renderers)
|
|
{
|
|
if (x.GetComponent<DC_SourceSettings>()) continue;
|
|
|
|
x.gameObject.AddComponent<DC_SourceSettings>();
|
|
|
|
reportBuilder.AppendLine($"为{x.name}添加了DC_SourceSettings");
|
|
}
|
|
|
|
Debug.Log(reportBuilder.ToString());
|
|
}
|
|
}
|
|
|
|
}
|