diff --git a/Editor/Editors/PropertyDrawers/YarnNodeAttributeDrawer.cs b/Editor/Editors/PropertyDrawers/YarnNodeAttributeDrawer.cs
index 8613c8b3..0284221c 100644
--- a/Editor/Editors/PropertyDrawers/YarnNodeAttributeDrawer.cs
+++ b/Editor/Editors/PropertyDrawers/YarnNodeAttributeDrawer.cs
@@ -232,6 +232,18 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
{
var name = node.Name;
+ if (!string.IsNullOrEmpty(attribute.filter))
+ {
+ var filter = attribute.filter.ToLower().Replace('-', '_');
+
+ switch (attribute.filterType)
+ {
+ case YarnNodeFilter.Contains: if (!name.ToLower().Contains(filter)) continue; break;
+ case YarnNodeFilter.Start: if (!name.ToLower().StartsWith(filter)) continue; break;
+ case YarnNodeFilter.End: if (!name.ToLower().EndsWith(filter)) continue; break;
+ }
+ }
+
menu.AddItem(new GUIContent(name), name == nodeName && !hasMixedNodeValues, () =>
{
property.stringValue = name;
diff --git a/Runtime/Attributes/YarnNodeAttribute.cs b/Runtime/Attributes/YarnNodeAttribute.cs
index 94546a2d..15e9efca 100644
--- a/Runtime/Attributes/YarnNodeAttribute.cs
+++ b/Runtime/Attributes/YarnNodeAttribute.cs
@@ -7,6 +7,8 @@ Yarn Spinner is licensed to you under the terms found in the file LICENSE.md.
namespace Yarn.Unity.Attributes
{
+ public enum YarnNodeFilter { None, Contains, Start, End }
+
///
/// Specifies that a field represents a reference to a named Yarn node that
/// exists in a Yarn project.
@@ -28,6 +30,16 @@ public class YarnNodeAttribute : PropertyAttribute
///
public readonly string yarnProjectAttribute;
+ ///
+ /// The text that specifies the Nodes you want to include in the dropdown.
+ ///
+ public readonly string filter;
+
+ ///
+ /// The filter type you'd like to use to find Nodes.
+ ///
+ public readonly YarnNodeFilter filterType;
+
public readonly bool requiresYarnProject;
///
@@ -35,10 +47,12 @@ public class YarnNodeAttribute : PropertyAttribute
///
///
- public YarnNodeAttribute(string yarnProjectAttribute, bool requiresYarnProject = true)
+ public YarnNodeAttribute(string yarnProjectAttribute, bool requiresYarnProject = true, string filter = default, YarnNodeFilter filterType = YarnNodeFilter.Contains)
{
this.yarnProjectAttribute = yarnProjectAttribute;
this.requiresYarnProject = requiresYarnProject;
+ this.filter = filter;
+ this.filterType = filterType;
}
}
}