using System; using UnityEditor.UIElements; using UnityEditor.Graphing; using UnityEditor.Graphing.Util; using UnityEngine.UIElements; namespace UnityEditor.ShaderGraph.Drawing.Inspector.PropertyDrawers { [SGPropertyDrawer(typeof(SamplerStateNode))] class SamplerStateNodeNodePropertyDrawer : AbstractMaterialNodePropertyDrawer { internal override void AddCustomNodeProperties(VisualElement parentElement, AbstractMaterialNode nodeBase, Action setNodesAsDirtyCallback, Action updateNodeViewsCallback) { var node = nodeBase as SamplerStateNode; var previewField = new EnumField(node.anisotropic); var propertyRow = new PropertyRow(new Label("Anisotropic Filtering")); propertyRow.Add(previewField, (field) => { field.RegisterValueChangedCallback(evt => { if (evt.newValue.Equals(node.anisotropic)) return; setNodesAsDirtyCallback?.Invoke(); node.owner.owner.RegisterCompleteObjectUndo("Change anisotropic filtering"); node.anisotropic = (TextureSamplerState.Anisotropic)evt.newValue; updateNodeViewsCallback?.Invoke(); node.Dirty(ModificationScope.Graph); }); }); parentElement.Add(propertyRow); } } }