/// <summary> /// Fetches every node connection declaration for each node type for later use /// </summary> public static void FetchNodeConnectionDeclarations() { nodePortDeclarations = new Dictionary <string, PortDeclaration[]> (); foreach (NodeTypeData nodeData in NodeTypes.getNodeDefinitions()) { Type nodeType = nodeData.type; List <PortDeclaration> declarations = new List <PortDeclaration> (); // Get all declared port fields FieldInfo[] declaredPorts = ReflectionUtility.getFieldsOfType(nodeType, typeof(Port)); foreach (FieldInfo portField in declaredPorts) { // Get info about that port declaration using the attribute object[] declAttrs = portField.GetCustomAttributes(typeof(Port.PortAttribute), true); if (declAttrs.Length < 1) { continue; } Port.PortAttribute declarationAttr = (Port.PortAttribute)declAttrs[0]; if (declarationAttr.MatchFieldType(portField.FieldType)) { declarations.Add(new PortDeclaration(portField, declarationAttr)); } else { Debug.LogError("Mismatched " + declarationAttr.GetType().Name + " for " + portField.FieldType.Name + " '" + declarationAttr.Name + "' on " + nodeData.type.Name + "!"); } } nodePortDeclarations.Add(nodeData.typeID, declarations.ToArray()); } }
public PortDeclaration(FieldInfo field, Port.PortAttribute attr) { portField = field; portInfo = attr; }