using System; using System.Linq; using UnityEditor.Graphing; using UnityEditor.ShaderGraph.Drawing.Controls; using UnityEngine; namespace UnityEditor.ShaderGraph { [Serializable] [Title("Master", "Unlit")] public class UnlitMasterNode : MasterNode { public const string ColorSlotName = "Color"; public const string AlphaSlotName = "Alpha"; public const string AlphaClipThresholdSlotName = "AlphaClipThreshold"; public const string VertexOffsetName = "VertexPosition"; public const int ColorSlotId = 0; public const int AlphaSlotId = 7; public const int AlphaThresholdSlotId = 8; [SerializeField] private SurfaceType m_SurfaceType; [EnumControl("Surface")] public SurfaceType surfaceType { get { return m_SurfaceType; } set { if (m_SurfaceType == value) return; m_SurfaceType = value; Dirty(ModificationScope.Graph); } } [SerializeField] private AlphaMode m_AlphaMode; [EnumControl("Blend")] public AlphaMode alphaMode { get { return m_AlphaMode; } set { if (m_AlphaMode == value) return; m_AlphaMode = value; Dirty(ModificationScope.Graph); } } [SerializeField] private bool m_TwoSided; [ToggleControl("Two Sided")] public Toggle twoSided { get { return new Toggle(m_TwoSided); } set { if (m_TwoSided == value.isOn) return; m_TwoSided = value.isOn; Dirty(ModificationScope.Graph); } } public UnlitMasterNode() { UpdateNodeAfterDeserialization(); } public override string documentationURL { get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Unlit-Master-Node"; } } public sealed override void UpdateNodeAfterDeserialization() { base.UpdateNodeAfterDeserialization(); name = "Unlit Master"; AddSlot(new ColorRGBMaterialSlot(ColorSlotId, ColorSlotName, ColorSlotName, SlotType.Input, Color.grey, ShaderStage.Fragment)); AddSlot(new Vector1MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, 1, ShaderStage.Fragment)); AddSlot(new Vector1MaterialSlot(AlphaThresholdSlotId, AlphaClipThresholdSlotName, AlphaClipThresholdSlotName, SlotType.Input, 0f, ShaderStage.Fragment)); // clear out slot names that do not match the slots // we support RemoveSlotsNameNotMatching( new[] { ColorSlotId, AlphaSlotId, AlphaThresholdSlotId }); } } }