41 lines
1.2 KiB
C#
41 lines
1.2 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;
|
|
[SerializeField] private bool allowCulling;
|
|
private void Awake()
|
|
{
|
|
GetComponent<MeshCombiner>().onCombiningReady += OnReady;
|
|
}
|
|
private void OnReady(MeshCombiner meshcombiner)
|
|
{
|
|
if(allowCulling is false)return;
|
|
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);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|