using System; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; // Include material common properties names using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; namespace UnityEditor.Rendering.HighDefinition { /// /// Represents the GUI for HDRP Shader Graph materials. /// public class DecalShaderGraphGUI : HDShaderGUI { [Flags] enum ExpandableBit : uint { SurfaceOptions = 1 << 0, SurfaceInputs = 1 << 1, Sorting = 1 << 2, } MaterialUIBlockList m_UIBlocks = new MaterialUIBlockList { new DecalSurfaceOptionsUIBlock((MaterialUIBlock.ExpandableBit)ExpandableBit.SurfaceOptions), new ShaderGraphUIBlock((MaterialUIBlock.ExpandableBit)ExpandableBit.SurfaceInputs, ShaderGraphUIBlock.Features.ExposedProperties), new DecalSortingInputsUIBlock((MaterialUIBlock.ExpandableBit)ExpandableBit.Sorting), }; /// The list of UI Blocks Unity uses to render the material inspector. protected MaterialUIBlockList uiBlocks => m_UIBlocks; /// /// Override this function to implement your custom GUI. To display a user interface similar to HDRP shaders, use a MaterialUIBlockList. /// /// The current material editor. /// The list of properties the material has. protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props) { uiBlocks.OnGUI(materialEditor, props); } /// /// Sets up the keywords and passes for a Decal Shader Graph material. /// /// The selected material. public static void SetupDecalKeywordsAndPass(Material material) => DecalAPI.SetupCommonDecalMaterialKeywordsAndPass(material); /// /// Sets up the keywords and passes for the current selected material. /// /// The selected material. public override void ValidateMaterial(Material material) => ShaderGraphAPI.ValidateDecalMaterial(material); } }