您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
38 行
973 B
38 行
973 B
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
public class StealLightmap : MonoBehaviour {
|
|
//public int LODIndex = 1;
|
|
private MeshRenderer currentRenderer;
|
|
public MeshRenderer lightmappedObject;
|
|
// Use this for initialization
|
|
private void OnEnable()
|
|
{
|
|
Awake();
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
currentRenderer = gameObject.GetComponent<MeshRenderer>();
|
|
RendererInfoTransfer();
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
void OnBecameVisible()
|
|
{
|
|
RendererInfoTransfer();
|
|
}
|
|
#endif
|
|
|
|
void RendererInfoTransfer()
|
|
{
|
|
if(lightmappedObject == null || currentRenderer == null)
|
|
return;
|
|
if(!currentRenderer.isPartOfStaticBatch)
|
|
{
|
|
currentRenderer.lightmapIndex = lightmappedObject.lightmapIndex;
|
|
currentRenderer.lightmapScaleOffset = lightmappedObject.lightmapScaleOffset;
|
|
currentRenderer.lightProbeUsage = lightmappedObject.lightProbeUsage;
|
|
}
|
|
}
|
|
}
|