A game about forced loneliness, made by TACStudios
1using System; 2using System.Reflection; 3using UnityEditor.UIElements; 4using UnityEngine; 5using UnityEngine.UIElements; 6 7namespace UnityEditor.ShaderGraph.Drawing.Controls 8{ 9 [AttributeUsage(AttributeTargets.Property)] 10 class ButtonControlAttribute : Attribute, IControlAttribute 11 { 12 public ButtonControlAttribute() 13 { 14 } 15 16 public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo) 17 { 18 return new ButtonControlView(node, propertyInfo); 19 } 20 } 21 22 [Serializable] 23 struct ButtonConfig 24 { 25 public string text; 26 public Action action; 27 } 28 29 class ButtonControlView : VisualElement 30 { 31 public ButtonControlView(AbstractMaterialNode node, PropertyInfo propertyInfo) 32 { 33 AbstractMaterialNode m_Node; 34 35 m_Node = node; 36 37 Type type = propertyInfo.PropertyType; 38 if (type != typeof(ButtonConfig)) 39 { 40 throw new ArgumentException("Property must be a ButtonConfig.", "propertyInfo"); 41 } 42 var value = (ButtonConfig)propertyInfo.GetValue(m_Node, null); 43 44 Add(new Button(value.action) { text = value.text }); 45 } 46 } 47}