您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
27 行
776 B
27 行
776 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class LightmapScaleSetter : MonoBehaviour
|
|
{
|
|
[SerializeField] private float _lightmapScale = 1f;
|
|
|
|
#if UNITY_EDITOR
|
|
// Called when the Lightmap Scale field is changed in the component editor
|
|
private void OnValidate()
|
|
{
|
|
// Clamp the lightmap scale to the range [0,1]
|
|
if (_lightmapScale < 0f)
|
|
{
|
|
_lightmapScale = 0f;
|
|
}
|
|
|
|
// Update lightmap scale for MeshRenderers within component and all descendants
|
|
MeshRenderer[] meshRenderers = GetComponentsInChildren<MeshRenderer>();
|
|
foreach (MeshRenderer meshRenderer in meshRenderers)
|
|
{
|
|
meshRenderer.scaleInLightmap = _lightmapScale;
|
|
}
|
|
}
|
|
#endif
|
|
}
|