You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

34 lines
1.4 KiB

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 SamplerStateNodePropertyDrawer : 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);
}
}
}