using UnityEditor; using UnityEditor.Rendering; /// /// Custom editor for the volumetric fog volume component. /// [CustomEditor(typeof(VolumetricFogVolumeComponent))] public sealed class VolumetricFogVolumeComponentEditor : VolumeComponentEditor { #region Private Attributes private SerializedDataParameter distance; private SerializedDataParameter baseHeight; private SerializedDataParameter maximumHeight; private SerializedDataParameter enableGround; private SerializedDataParameter groundHeight; private SerializedDataParameter density; private SerializedDataParameter attenuationDistance; #if UNITY_2023_1_OR_NEWER private SerializedDataParameter enableAPVContribution; private SerializedDataParameter APVContributionWeight; #endif private SerializedDataParameter enableMainLightContribution; private SerializedDataParameter anisotropy; private SerializedDataParameter scattering; private SerializedDataParameter tint; private SerializedDataParameter enableAdditionalLightsContribution; private SerializedDataParameter maxSteps; private SerializedDataParameter blurIterations; private SerializedDataParameter enabled; private SerializedDataParameter renderPassEvent; #endregion #region VolumeComponentEditor Methods /// /// /// public override void OnEnable() { PropertyFetcher pf = new PropertyFetcher(serializedObject); distance = Unpack(pf.Find(x => x.distance)); baseHeight = Unpack(pf.Find(x => x.baseHeight)); maximumHeight = Unpack(pf.Find(x => x.maximumHeight)); enableGround = Unpack(pf.Find(x => x.enableGround)); groundHeight = Unpack(pf.Find(x => x.groundHeight)); density = Unpack(pf.Find(x => x.density)); attenuationDistance = Unpack(pf.Find(x => x.attenuationDistance)); #if UNITY_2023_1_OR_NEWER enableAPVContribution = Unpack(pf.Find(x => x.enableAPVContribution)); APVContributionWeight = Unpack(pf.Find(x => x.APVContributionWeight)); #endif enableMainLightContribution = Unpack(pf.Find(x => x.enableMainLightContribution)); anisotropy = Unpack(pf.Find(x => x.anisotropy)); scattering = Unpack(pf.Find(x => x.scattering)); tint = Unpack(pf.Find(x => x.tint)); enableAdditionalLightsContribution = Unpack(pf.Find(x => x.enableAdditionalLightsContribution)); maxSteps = Unpack(pf.Find(x => x.maxSteps)); blurIterations = Unpack(pf.Find(x => x.blurIterations)); enabled = Unpack(pf.Find(x => x.enabled)); renderPassEvent = Unpack(pf.Find(x => x.renderPassEvent)); } /// /// /// public override void OnInspectorGUI() { bool isEnabled = enabled.overrideState.boolValue && enabled.value.boolValue; if (!isEnabled) { PropertyField(enabled); return; } bool enabledGround = enableGround.overrideState.boolValue && enableGround.value.boolValue; bool enabledMainLightContribution = enableMainLightContribution.overrideState.boolValue && enableMainLightContribution.value.boolValue; bool enabledAdditionalLightsContribution = enableAdditionalLightsContribution.overrideState.boolValue && enableAdditionalLightsContribution.value.boolValue; PropertyField(distance); PropertyField(baseHeight); PropertyField(maximumHeight); PropertyField(enableGround); if (enabledGround) PropertyField(groundHeight); PropertyField(density); PropertyField(attenuationDistance); #if UNITY_2023_1_OR_NEWER bool enabledAPVContribution = enableAPVContribution.overrideState.boolValue && enableAPVContribution.value.boolValue; PropertyField(enableAPVContribution); if (enabledAPVContribution) PropertyField(APVContributionWeight); #endif PropertyField(enableMainLightContribution); if (enabledMainLightContribution) { PropertyField(anisotropy); PropertyField(scattering); PropertyField(tint); } PropertyField(enableAdditionalLightsContribution); PropertyField(maxSteps); PropertyField(blurIterations); PropertyField(enabled); PropertyField(renderPassEvent); } #endregion }