您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
51 行
1.1 KiB
51 行
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Profiling;
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
using UnityEditor;
|
|
|
|
[ExecuteInEditMode]
|
|
public class ProjectLODLightmapManager : MonoBehaviour {
|
|
|
|
void OnEnable()
|
|
{
|
|
EditorApplication.playModeStateChanged += PlayModeChange;
|
|
Lightmapping.completed += SetupRenderers;
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
EditorApplication.playModeStateChanged -= PlayModeChange;
|
|
Lightmapping.completed -= SetupRenderers;
|
|
}
|
|
|
|
void Start ()
|
|
{
|
|
SetupRenderers();
|
|
}
|
|
|
|
static void PlayModeChange(PlayModeStateChange state)
|
|
{
|
|
if (state == PlayModeStateChange.ExitingPlayMode)
|
|
{
|
|
SetupRenderers();
|
|
}
|
|
}
|
|
|
|
static void SetupRenderers()
|
|
{
|
|
Profiler.BeginSample("ProjectLODLightmapManager.SetupRenderers");
|
|
ProjectLODLightmaps[] projectors = FindObjectsOfType<ProjectLODLightmaps>();
|
|
|
|
foreach (var projector in projectors)
|
|
{
|
|
projector.SetupRenderer();
|
|
}
|
|
Profiler.EndSample();
|
|
}
|
|
}
|
|
|
|
#endif
|