using UnityEngine;
namespace UnityEditor.Rendering.HighDefinition
{
///
/// The UI block that represents surface inputs for unlit materials.
///
public class UnlitSurfaceInputsUIBlock : MaterialUIBlock
{
internal class Styles
{
public static GUIContent header { get; } = EditorGUIUtility.TrTextContent("Surface Inputs");
public static GUIContent colorText = new GUIContent("Color", " Albedo (RGB) and Transparency (A).");
public static GUIContent alphaRemappingText = new GUIContent("Alpha Remapping", "Controls a remap for the alpha channel in the Base Color.");
}
MaterialProperty color = null;
const string kColor = "_UnlitColor";
MaterialProperty colorMap = null;
const string kColorMap = "_UnlitColorMap";
MaterialProperty alphaRemapMin = null;
const string kAlphaRemapMin = "_AlphaRemapMin";
MaterialProperty alphaRemapMax = null;
const string kAlphaRemapMax = "_AlphaRemapMax";
///
/// Constructs an UnlitSurfaceInputsUIBlock based on the parameters.
///
/// Bit index used to store the foldout state.
public UnlitSurfaceInputsUIBlock(ExpandableBit expandableBit)
: base(expandableBit, Styles.header)
{
}
///
/// Loads the material properties for the block.
///
public override void LoadMaterialProperties()
{
color = FindProperty(kColor);
colorMap = FindProperty(kColorMap);
alphaRemapMin = FindProperty(kAlphaRemapMin);
alphaRemapMax = FindProperty(kAlphaRemapMax);
}
///
/// Renders the properties in the block.
///
protected override void OnGUIOpen()
{
materialEditor.TexturePropertySingleLine(Styles.colorText, colorMap, color);
if (colorMap.textureValue != null)
{
materialEditor.MinMaxShaderProperty(alphaRemapMin, alphaRemapMax, 0.0f, 1.0f, Styles.alphaRemappingText);
}
materialEditor.TextureScaleOffsetProperty(colorMap);
}
}
}