mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Cleanup
Postfixed attribute classes with Attribute Added Attributes region
This commit is contained in:
parent
973f9beb1d
commit
84e2af7916
@ -42,9 +42,9 @@ namespace XNodeEditor {
|
|||||||
public static Dictionary<Type, Color> GetNodeTint() {
|
public static Dictionary<Type, Color> GetNodeTint() {
|
||||||
Dictionary<Type, Color> tints = new Dictionary<Type, Color>();
|
Dictionary<Type, Color> tints = new Dictionary<Type, Color>();
|
||||||
for (int i = 0; i < nodeTypes.Length; i++) {
|
for (int i = 0; i < nodeTypes.Length; i++) {
|
||||||
var attribs = nodeTypes[i].GetCustomAttributes(typeof(XNode.Node.NodeTint), true);
|
var attribs = nodeTypes[i].GetCustomAttributes(typeof(XNode.Node.NodeTintAttribute), true);
|
||||||
if (attribs == null || attribs.Length == 0) continue;
|
if (attribs == null || attribs.Length == 0) continue;
|
||||||
XNode.Node.NodeTint attrib = attribs[0] as XNode.Node.NodeTint;
|
XNode.Node.NodeTintAttribute attrib = attribs[0] as XNode.Node.NodeTintAttribute;
|
||||||
tints.Add(nodeTypes[i], attrib.color);
|
tints.Add(nodeTypes[i], attrib.color);
|
||||||
}
|
}
|
||||||
return tints;
|
return tints;
|
||||||
@ -53,9 +53,9 @@ namespace XNodeEditor {
|
|||||||
public static Dictionary<Type, int> GetNodeWidth() {
|
public static Dictionary<Type, int> GetNodeWidth() {
|
||||||
Dictionary<Type, int> widths = new Dictionary<Type, int>();
|
Dictionary<Type, int> widths = new Dictionary<Type, int>();
|
||||||
for (int i = 0; i < nodeTypes.Length; i++) {
|
for (int i = 0; i < nodeTypes.Length; i++) {
|
||||||
var attribs = nodeTypes[i].GetCustomAttributes(typeof(XNode.Node.NodeWidth), true);
|
var attribs = nodeTypes[i].GetCustomAttributes(typeof(XNode.Node.NodeWidthAttribute), true);
|
||||||
if (attribs == null || attribs.Length == 0) continue;
|
if (attribs == null || attribs.Length == 0) continue;
|
||||||
XNode.Node.NodeWidth attrib = attribs[0] as XNode.Node.NodeWidth;
|
XNode.Node.NodeWidthAttribute attrib = attribs[0] as XNode.Node.NodeWidthAttribute;
|
||||||
widths.Add(nodeTypes[i], attrib.width);
|
widths.Add(nodeTypes[i], attrib.width);
|
||||||
}
|
}
|
||||||
return widths;
|
return widths;
|
||||||
|
|||||||
@ -63,7 +63,6 @@ namespace XNode {
|
|||||||
/// <summary> Used during node instantiation to fix null/misconfigured graph during OnEnable/Init. Set it before instantiating a node. Will automatically be unset during OnEnable </summary>
|
/// <summary> Used during node instantiation to fix null/misconfigured graph during OnEnable/Init. Set it before instantiating a node. Will automatically be unset during OnEnable </summary>
|
||||||
public static NodeGraph graphHotfix;
|
public static NodeGraph graphHotfix;
|
||||||
|
|
||||||
|
|
||||||
protected void OnEnable() {
|
protected void OnEnable() {
|
||||||
if (graphHotfix != null) graph = graphHotfix;
|
if (graphHotfix != null) graph = graphHotfix;
|
||||||
graphHotfix = null;
|
graphHotfix = null;
|
||||||
@ -210,6 +209,7 @@ namespace XNode {
|
|||||||
return JsonUtility.ToJson(this).GetHashCode();
|
return JsonUtility.ToJson(this).GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Attributes
|
||||||
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInputPort(string)"/> </summary>
|
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInputPort(string)"/> </summary>
|
||||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
|
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
|
||||||
public class InputAttribute : Attribute {
|
public class InputAttribute : Attribute {
|
||||||
@ -255,19 +255,19 @@ namespace XNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||||
public class NodeTint : Attribute {
|
public class NodeTintAttribute : Attribute {
|
||||||
public Color color;
|
public Color color;
|
||||||
/// <summary> Specify a color for this node type </summary>
|
/// <summary> Specify a color for this node type </summary>
|
||||||
/// <param name="r"> Red [0.0f .. 1.0f] </param>
|
/// <param name="r"> Red [0.0f .. 1.0f] </param>
|
||||||
/// <param name="g"> Green [0.0f .. 1.0f] </param>
|
/// <param name="g"> Green [0.0f .. 1.0f] </param>
|
||||||
/// <param name="b"> Blue [0.0f .. 1.0f] </param>
|
/// <param name="b"> Blue [0.0f .. 1.0f] </param>
|
||||||
public NodeTint(float r, float g, float b) {
|
public NodeTintAttribute(float r, float g, float b) {
|
||||||
color = new Color(r, g, b);
|
color = new Color(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Specify a color for this node type </summary>
|
/// <summary> Specify a color for this node type </summary>
|
||||||
/// <param name="hex"> HEX color value </param>
|
/// <param name="hex"> HEX color value </param>
|
||||||
public NodeTint(string hex) {
|
public NodeTintAttribute(string hex) {
|
||||||
ColorUtility.TryParseHtmlString(hex, out color);
|
ColorUtility.TryParseHtmlString(hex, out color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,20 +275,21 @@ namespace XNode {
|
|||||||
/// <param name="r"> Red [0 .. 255] </param>
|
/// <param name="r"> Red [0 .. 255] </param>
|
||||||
/// <param name="g"> Green [0 .. 255] </param>
|
/// <param name="g"> Green [0 .. 255] </param>
|
||||||
/// <param name="b"> Blue [0 .. 255] </param>
|
/// <param name="b"> Blue [0 .. 255] </param>
|
||||||
public NodeTint(byte r, byte g, byte b) {
|
public NodeTintAttribute(byte r, byte g, byte b) {
|
||||||
color = new Color32(r, g, b, byte.MaxValue);
|
color = new Color32(r, g, b, byte.MaxValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||||
public class NodeWidth : Attribute {
|
public class NodeWidthAttribute : Attribute {
|
||||||
public int width;
|
public int width;
|
||||||
/// <summary> Specify a width for this node type </summary>
|
/// <summary> Specify a width for this node type </summary>
|
||||||
/// <param name="width"> Width </param>
|
/// <param name="width"> Width </param>
|
||||||
public NodeWidth(int width) {
|
public NodeWidthAttribute(int width) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
[Serializable] private class NodePortDictionary : Dictionary<string, NodePort>, ISerializationCallbackReceiver {
|
[Serializable] private class NodePortDictionary : Dictionary<string, NodePort>, ISerializationCallbackReceiver {
|
||||||
[SerializeField] private List<string> keys = new List<string>();
|
[SerializeField] private List<string> keys = new List<string>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user