您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
43 行
1.1 KiB
43 行
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(LODGroup))][ExecuteInEditMode]
|
|
public class LODLightmaps : MonoBehaviour {
|
|
|
|
LODGroup _lodGrp;
|
|
Renderer[] _main;
|
|
Renderer[] _LOD1;
|
|
Renderer[] _LOD2;
|
|
|
|
void Awake ()
|
|
{
|
|
CopyLightmapSettings();
|
|
}
|
|
|
|
void CopyLightmapSettings()
|
|
{
|
|
_lodGrp = GetComponent<LODGroup>();
|
|
LOD[] lods = _lodGrp.GetLODs();
|
|
_main = lods[0].renderers;
|
|
_LOD1 = lods[1].renderers;
|
|
_LOD2 = lods[2].renderers;
|
|
|
|
int[] lmIndex = new int[_main.Length];
|
|
Vector4[] lmScaleOffset = new Vector4[_main.Length];
|
|
|
|
for (var i = 0; i < _main.Length; i++)
|
|
{
|
|
lmIndex[i] = _main[i].lightmapIndex;
|
|
lmScaleOffset[i] = _main[i].lightmapScaleOffset;
|
|
}
|
|
|
|
for (var i = 0; i < _main.Length; i++)
|
|
{
|
|
_LOD1[i].lightmapIndex = lmIndex[i];
|
|
_LOD1[i].lightmapScaleOffset = lmScaleOffset[i];
|
|
_LOD2[i].lightmapIndex = lmIndex[i];
|
|
_LOD2[i].lightmapScaleOffset = lmScaleOffset[i];
|
|
}
|
|
}
|
|
}
|