Net.Like.Xue.Tokyo/Assets/Artists/Scripts/WorldOptimizeService.cs

39 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using MeshCombineStudio;
using NGS.AdvancedCullingSystem.Dynamic;
using UnityEngine;
namespace Net.Like.Xue.Tokyo
{
public class WorldOptimizeService : MonoBehaviour
{
[SerializeField] private Transform[] sources;
[SerializeField] private Camera minimapCamera;
private void Awake()
{
GetComponent<MeshCombiner>().onCombiningReady += OnReady;
}
private void OnReady(MeshCombiner meshcombiner)
{
minimapCamera.Render();
minimapCamera.enabled = false;
var controller = gameObject.AddComponent<DC_Controller>();
controller.AddCamera(Camera.main,3000);
foreach (var x in sources)
{
foreach (var renderer in x.GetComponentsInChildren<MeshRenderer>())
{
if (renderer.gameObject.activeInHierarchy)
controller.AddObjectForCulling(renderer);
}
}
}
}
}