using System.Collections; using System.Collections.Generic; using UnityEngine; using System; namespace GraphProcessor { /// /// Tell that this field is will generate an input port /// [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class InputAttribute : Attribute { public string name; public bool allowMultiple = false; /// /// Mark the field as an input port /// /// display name /// is connecting multiple edges allowed public InputAttribute(string name = null, bool allowMultiple = false) { this.name = name; this.allowMultiple = allowMultiple; } } /// /// Tell that this field is will generate an output port /// [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class OutputAttribute : Attribute { public string name; public bool allowMultiple = true; /// /// Mark the field as an output port /// /// display name /// is connecting multiple edges allowed public OutputAttribute(string name = null, bool allowMultiple = true) { this.name = name; this.allowMultiple = allowMultiple; } } /// /// Creates a vertical port instead of the default horizontal one /// [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class VerticalAttribute : Attribute { } /// /// Register the node in the NodeProvider class. The node will also be available in the node creation window. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class NodeMenuItemAttribute : Attribute { public string menuTitle; public Type onlyCompatibleWithGraph; /// /// Register the node in the NodeProvider class. The node will also be available in the node creation window. /// /// Path in the menu, use / as folder separators public NodeMenuItemAttribute(string menuTitle = null, Type onlyCompatibleWithGraph = null) { this.menuTitle = menuTitle; this.onlyCompatibleWithGraph = onlyCompatibleWithGraph; } } /// /// Set a custom drawer for a field. It can then be created using the FieldFactory /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] [Obsolete("You can use the standard Unity CustomPropertyDrawer instead.")] public class FieldDrawerAttribute : Attribute { public Type fieldType; /// /// Register a custom view for a type in the FieldFactory class /// /// public FieldDrawerAttribute(Type fieldType) { this.fieldType = fieldType; } } /// /// Allow you to customize the input function of a port /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class CustomPortInputAttribute : Attribute { public string fieldName; public Type inputType; public bool allowCast; /// /// Allow you to customize the input function of a port. /// See CustomPortsNode example in Samples. /// /// local field of the node /// type of input of the port /// if cast is allowed when connecting an edge public CustomPortInputAttribute(string fieldName, Type inputType, bool allowCast = true) { this.fieldName = fieldName; this.inputType = inputType; this.allowCast = allowCast; } } /// /// Allow you to customize the input function of a port /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class CustomPortOutputAttribute : Attribute { public string fieldName; public Type outputType; public bool allowCast; /// /// Allow you to customize the output function of a port. /// See CustomPortsNode example in Samples. /// /// local field of the node /// type of input of the port /// if cast is allowed when connecting an edge public CustomPortOutputAttribute(string fieldName, Type outputType, bool allowCast = true) { this.fieldName = fieldName; this.outputType = outputType; this.allowCast = allowCast; } } /// /// Allow you to modify the generated port view from a field. Can be used to generate multiple ports from one field. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class CustomPortBehaviorAttribute : Attribute { public string fieldName; /// /// Allow you to modify the generated port view from a field. Can be used to generate multiple ports from one field. /// You must add this attribute on a function of this signature /// /// IEnumerable<PortData> MyCustomPortFunction(List<SerializableEdge> edges); /// /// /// local node field name public CustomPortBehaviorAttribute(string fieldName) { this.fieldName = fieldName; } } /// /// Allow to bind a method to generate a specific set of ports based on a field type in a node /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class CustomPortTypeBehavior : Attribute { /// /// Target type /// public Type type; public CustomPortTypeBehavior(Type type) { this.type = type; } } /// /// Allow you to have a custom view for your stack nodes /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public class CustomStackNodeView : Attribute { public Type stackNodeType; /// /// Allow you to have a custom view for your stack nodes /// /// The type of the stack node you target public CustomStackNodeView(Type stackNodeType) { this.stackNodeType = stackNodeType; } } [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class VisibleIf : Attribute { public string fieldName; public object value; public VisibleIf(string fieldName, object value) { this.fieldName = fieldName; this.value = value; } } [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class ShowInInspector : Attribute { public bool showInNode; public ShowInInspector(bool showInNode = false) { this.showInNode = showInNode; } } [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class ShowAsDrawer : Attribute { } [AttributeUsage(AttributeTargets.Field)] public class SettingAttribute : Attribute { public string name; public SettingAttribute(string name = null) { this.name = name; } } [AttributeUsage(AttributeTargets.Method)] public class IsCompatibleWithGraph : Attribute {} }