Game.Rendering.Debug.LodParametersSetter
Assembly:
Assembly-CSharp (game runtime assembly that contains game code and most mod-facing types)
Namespace:
Game.Rendering.Debug
Type:
public class LodParametersSetter : UnityEngine.MonoBehaviour
Base:
UnityEngine.MonoBehaviour
Summary:
Component that overrides a global shader vector used by the game's rendering shaders to control LOD-related parameters. Each frame this component writes the public Vector4 m_LODParameter into the global shader property identified by RenderPrefabRenderer.ShaderIDs._LodParameters. Intended for debugging or temporarily forcing custom LOD behavior at runtime (for example to change LOD distances or bias).
Fields
public UnityEngine.Vector4 m_LODParameter
Public vector exposed to the Inspector. Its components are used by shaders that read the global _LodParameters vector (the meaning of each component depends on the shader implementation; by default this script initializes it to (100000f, 1f, 0f, 0f) in the source). Modify this value to change LOD behavior globally.
Properties
- None
Constructors
public LodParametersSetter()
MonoBehaviour types typically rely on Unity lifecycle methods rather than explicit constructors. This class does not define a custom constructor — use Awake/Start or set fields in the Inspector.
Methods
public void Update()
Called every frame by Unity. This method calls: Shader.SetGlobalVector(RenderPrefabRenderer.ShaderIDs._LodParameters, m_LODParameter); which writes the current m_LODParameter value into the global shader state so that all shaders accessing _LodParameters will use the provided vector.
Notes: - Because Update runs each frame, consider updating the global vector only when the value actually changes if you need to avoid unnecessary per-frame work. - Shader.SetGlobalVector must be called from the main thread (Unity thread). - The exact interpretation of the vector components (x, y, z, w) is determined by the shaders that read _LodParameters (see RenderPrefabRenderer.ShaderIDs and relevant shader source for details).
Usage Example
// Create a GameObject and attach the setter at runtime:
using UnityEngine;
public class LodSetterExample : MonoBehaviour
{
void Start()
{
var go = new GameObject("LOD Override");
var setter = go.AddComponent<Game.Rendering.Debug.LodParametersSetter>();
// Set custom LOD parameters (example values)
setter.m_LODParameter = new Vector4(500f, 1f, 0f, 0f);
// Leave the GameObject in the scene to apply the override each frame.
}
}
Additional tips: - For temporary debugging, attach the component to an always-active GameObject (e.g., a persistent debugger object). - To minimize overhead in production, remove or disable this component once testing is complete.