using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; namespace UnityEditor.Rendering.HighDefinition { class WaterDecalSurfaceOptionsUIBlock : MaterialUIBlock { internal class Styles { public static GUIContent header { get; } = EditorGUIUtility.TrTextContent("Surface Options"); public static GUIContent affectsDeformationText = new GUIContent("Affect Deformation", "When enabled, this decal can affect deformation.\nDeformation should be a normalized value between -1 and 1."); public static GUIContent affectsFoamText = new GUIContent("Affect Foam", "When enabled, this decal can affect foam."); public static GUIContent affectsSimulationMaskText = new GUIContent("Affect Simulation Mask", "When enabled, this decal can affect simulation mask and simulation foam mask."); public static GUIContent affectsLargeCurrentText = new GUIContent("Affect Large Current", "When enabled, this decal can affect the swell current on oceans and the agitation current current on rivers."); public static GUIContent affectsRipplesCurrentText = new GUIContent("Affect Ripples Current", "When enabled, this decal can affect ripples current."); } MaterialProperty affectsDeformation; MaterialProperty affectsFoam; MaterialProperty affectsSimulationMask; MaterialProperty affectsLargeCurrent; MaterialProperty affectsRipplesCurrent; /// /// /// Constructs a DecalSurfaceOptionsUIBlock based on the parameters. /// Bit index used to store the foldout state. public WaterDecalSurfaceOptionsUIBlock(ExpandableBit expandableBit) : base(expandableBit, Styles.header) { } /// /// Loads the material properties for the block. /// public override void LoadMaterialProperties() { affectsDeformation = FindProperty(HDShaderIDs.kAffectsDeformation); affectsFoam = FindProperty(HDShaderIDs.kAffectsFoam); affectsSimulationMask = FindProperty(HDShaderIDs.kAffectsSimulationMask); affectsLargeCurrent = FindProperty(HDShaderIDs.kAffectsLargeCurrent); affectsRipplesCurrent = FindProperty(HDShaderIDs.kAffectsRipplesCurrent); } void AffectProperty(MaterialProperty property, GUIContent style, bool requireGlobalSetting = false) { if (property == null) return; materialEditor.ShaderProperty(property, style); if (requireGlobalSetting && property.floatValue > 0.0f && !GraphicsSettings.GetRenderPipelineSettings().waterDecalMaskAndCurrent) { EditorGUILayout.Space(); HDEditorUtils.GlobalSettingsHelpBox("Water decals affecting mask and current is not enabled in the HDRP Global Settings.", MessageType.Error); } } /// /// Renders the properties in the block. /// protected override void OnGUIOpen() { AffectProperty(affectsDeformation, Styles.affectsDeformationText); AffectProperty(affectsFoam, Styles.affectsFoamText); AffectProperty(affectsSimulationMask, Styles.affectsSimulationMaskText, true); AffectProperty(affectsLargeCurrent, Styles.affectsLargeCurrentText, true); AffectProperty(affectsRipplesCurrent, Styles.affectsRipplesCurrentText, true); } } }