2 using System.Reflection;
3 using UnityEditor.UIElements;
5 using UnityEngine.UIElements;
7 namespace UnityEditor.ShaderGraph.Drawing.Controls
9 [AttributeUsage(AttributeTargets.Property)]
10 class ButtonControlAttribute : Attribute, IControlAttribute
12 public ButtonControlAttribute()
16 public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
18 return new ButtonControlView(node, propertyInfo);
29 class ButtonControlView : VisualElement
31 public ButtonControlView(AbstractMaterialNode node, PropertyInfo propertyInfo)
33 AbstractMaterialNode m_Node;
37 Type type = propertyInfo.PropertyType;
38 if (type != typeof(ButtonConfig))
40 throw new ArgumentException("Property must be a ButtonConfig.", "propertyInfo");
42 var value = (ButtonConfig)propertyInfo.GetValue(m_Node, null);
44 Add(new Button(value.action) { text = value.text});