Files
MinFt/Client/Assets/MeshBaker/scripts/MB_PreserveLightmapData.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

41 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DigitalOpus.MB.Core;
/// <summary>
/// This script is used to fix a bug where lightmapping on combined meshes
/// is not preserved after reloading a scene or entering gamemode. This problem
/// was caused by the lightmap index and scale offset data being lost. This script
/// sets the lightmap index and scale offset back to where it should be so that lightmapping
/// is actually preserved.
/// </summary>
[ExecuteInEditMode]
public class MB_PreserveLightmapData : MonoBehaviour
{
public int lightmapIndex;
public Vector4 lightmapScaleOffset;
void Awake()
{
MeshRenderer curRend = GetComponent<MeshRenderer>();
if (curRend == null)
{
Debug.LogError("The MB_PreserveLightmapData script must be on a GameObject with a MeshRenderer. There was no MeshRenderer on object: " + name);
return;
}
if (curRend.lightmapIndex != -1)
{
lightmapIndex = curRend.lightmapIndex;
}
if (curRend.lightmapIndex == -1)
{
curRend.lightmapIndex = lightmapIndex;
}
lightmapScaleOffset = new Vector4(1, 1, 0, 0);
curRend.lightmapScaleOffset = lightmapScaleOffset;
}
}