浏览代码

Add lightmap scale setter tool (#452)

* Add component with settable field, clamped to [0,1] range

* Get all MeshRenderers in component & children (recursively)

* Modfiy lightmap scale of all MeshRenderers

* Cleanup/comments

* Move tool to Scripts/EditorTools

* Update LightmapScaleSetter.cs

Removed the cap at 1f

Co-authored-by: Ciro Continisio <ciro@unity3d.com>
/main
GitHub 3 年前
当前提交
d5fb01f9
共有 2 个文件被更改,包括 36 次插入0 次删除
  1. 25
      UOP1_Project/Assets/Scripts/EditorTools/LightmapScaleSetter.cs
  2. 11
      UOP1_Project/Assets/Scripts/EditorTools/LightmapScaleSetter.cs.meta

25
UOP1_Project/Assets/Scripts/EditorTools/LightmapScaleSetter.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LightmapScaleSetter : MonoBehaviour
{
[SerializeField] private float _lightmapScale = 1f;
// 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;
}
}
}

11
UOP1_Project/Assets/Scripts/EditorTools/LightmapScaleSetter.cs.meta


fileFormatVersion: 2
guid: fbb385c100ec94130b043785fa7af40e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存