using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
internal class UniversalRenderPipelineSerializedLight : ISerializedLight
{
/// The base settings of the light
public LightEditor.Settings settings { get; }
/// The light serialized
public SerializedObject serializedObject { get; }
/// The additional light data serialized
public SerializedObject serializedAdditionalDataObject { get; private set; }
public UniversalAdditionalLightData additionalLightData => lightsAdditionalData[0];
public UniversalAdditionalLightData[] lightsAdditionalData { get; private set; }
// Common SRP's Lights properties
public SerializedProperty intensity { get; }
// URP Light Properties
public SerializedProperty useAdditionalDataProp { get; } // Does light use shadow bias settings defined in UniversalRP asset file?
public SerializedProperty additionalLightsShadowResolutionTierProp { get; } // Index of the AdditionalLights ShadowResolution Tier
public SerializedProperty softShadowQualityProp { get; } // Per light soft shadow filtering quality.
public SerializedProperty lightCookieSizeProp { get; } // Multi dimensional light cookie size replacing `cookieSize` in legacy light.
public SerializedProperty lightCookieOffsetProp { get; } // Multi dimensional light cookie offset.
// Light layers related
public SerializedProperty renderingLayers { get; }
public SerializedProperty customShadowLayers { get; }
public SerializedProperty shadowRenderingLayers { get; }
/// Method that updates the of the Light and the Additional Light Data
public void Update()
{
serializedObject.Update();
serializedAdditionalDataObject.Update();
settings.Update();
}
/// Method that applies the modified properties the of the Light and the Light Camera Data
public void Apply()
{
serializedObject.ApplyModifiedProperties();
serializedAdditionalDataObject.ApplyModifiedProperties();
settings.ApplyModifiedProperties();
}
/// Constructor
/// with the light
/// with the settings
public UniversalRenderPipelineSerializedLight(SerializedObject serializedObject, LightEditor.Settings settings)
{
this.settings = settings;
settings.OnEnable();
this.serializedObject = serializedObject;
lightsAdditionalData = CoreEditorUtils
.GetAdditionalData(serializedObject.targetObjects);
serializedAdditionalDataObject = new SerializedObject(lightsAdditionalData);
intensity = serializedObject.FindProperty("m_Intensity");
useAdditionalDataProp = serializedAdditionalDataObject.FindProperty("m_UsePipelineSettings");
additionalLightsShadowResolutionTierProp = serializedAdditionalDataObject.FindProperty("m_AdditionalLightsShadowResolutionTier");
softShadowQualityProp = serializedAdditionalDataObject.FindProperty("m_SoftShadowQuality");
lightCookieSizeProp = serializedAdditionalDataObject.FindProperty("m_LightCookieSize");
lightCookieOffsetProp = serializedAdditionalDataObject.FindProperty("m_LightCookieOffset");
renderingLayers = serializedAdditionalDataObject.FindProperty("m_RenderingLayers");
customShadowLayers = serializedAdditionalDataObject.FindProperty("m_CustomShadowLayers");
shadowRenderingLayers = serializedAdditionalDataObject.FindProperty("m_ShadowRenderingLayers");
settings.ApplyModifiedProperties();
}
}
}