A game about forced loneliness, made by TACStudios
at master 2.6 kB view raw
1using System; 2using UnityEditor.Graphing; 3using UnityEditor.ShaderGraph.Drawing.Slots; 4using UnityEditor.ShaderGraph.Internal; 5using UnityEngine.UIElements; 6 7namespace UnityEditor.ShaderGraph 8{ 9 [Serializable] 10 class PropertyConnectionStateMaterialSlot : MaterialSlot, IMaterialSlotHasValue<bool> 11 { 12 public PropertyConnectionStateMaterialSlot() 13 { } 14 15 public PropertyConnectionStateMaterialSlot( 16 int slotId, 17 string displayName, 18 string shaderOutputName, 19 SlotType slotType, 20 ShaderStageCapability stageCapability = ShaderStageCapability.All, 21 bool hidden = false) 22 : base(slotId, displayName, shaderOutputName, slotType, stageCapability, hidden) 23 { 24 } 25 26 public override VisualElement InstantiateControl() 27 { 28 return new PropertyConnectionStateSlotControlView(this); 29 } 30 31 protected override string ConcreteSlotValueAsVariable() 32 { 33 // This is a funky slot, that doesn't directly hold a value. 34 return "false"; 35 } 36 37 public bool defaultValue 38 { 39 // This is a funky slot, that doesn't directly hold a value. 40 get { return false; } 41 } 42 43 public bool value 44 { 45 // This is a funky slot, that doesn't directly hold a value. 46 get { return false; } 47 } 48 49 public override bool isDefaultValue => true; 50 51 public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode) 52 { 53 if (!generationMode.IsPreview()) 54 return; 55 56 if (owner == null) 57 throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode))); 58 59 var property = new BooleanShaderProperty() 60 { 61 overrideReferenceName = owner.GetVariableNameForSlot(id), 62 generatePropertyBlock = false, 63 value = isConnected 64 }; 65 properties.AddShaderProperty(property); 66 } 67 68 public override SlotValueType valueType { get { return SlotValueType.PropertyConnectionState; } } 69 public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.PropertyConnectionState; } } 70 71 public override void CopyValuesFrom(MaterialSlot foundSlot) 72 { 73 // This is a funky slot, that doesn't directly hold a value. 74 } 75 } 76}