Exemple #1
0
 /// <summary>
 /// Fetches every node connection declaration for each node type for later use
 /// </summary>
 public static void FetchNodeConnectionDeclarations()
 {
     nodePortDeclarations = new Dictionary <string, ConnectionPortDeclaration[]> ();
     foreach (NodeTypeData nodeData in NodeTypes.GetAllNodeTypeData())
     {
         Type nodeType = nodeData.type;
         List <ConnectionPortDeclaration> declarations = new List <ConnectionPortDeclaration> ();
         // Get all declared port fields
         FieldInfo[] declaredPorts = ReflectionUtility.getFieldsOfType(nodeType, typeof(ConnectionPort));
         foreach (FieldInfo portField in declaredPorts)
         {                 // Get info about that port declaration using the attribute
             object[] declAttrs = portField.GetCustomAttributes(typeof(ConnectionPortAttribute), true);
             if (declAttrs.Length < 1)
             {
                 continue;
             }
             ConnectionPortAttribute declarationAttr = (ConnectionPortAttribute)declAttrs[0];
             if (declarationAttr.MatchFieldType(portField.FieldType))
             {
                 declarations.Add(new ConnectionPortDeclaration(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());
     }
 }
Exemple #2
0
        public ConnectionPort CreateConnectionPort(ConnectionPortAttribute specificationAttribute)
        {
            ConnectionPort port = specificationAttribute.CreateNew(this);

            if (port == null)
            {
                return(null);
            }
            dynamicConnectionPorts.Add(port);
            ConnectionPortManager.UpdateRepresentativePortLists(this);
            return(port);
        }
Exemple #3
0
 //Edit to framework: (added to support inserting connection ports at an index)
 public ConnectionPort CreateConnectionPort(ConnectionPortAttribute specificationAttribute, int index)
 {
     if (index >= 0 && index <= dynamicConnectionPorts.Count)
     {
         ConnectionPort port = specificationAttribute.CreateNew(this);
         if (port == null)
         {
             return(null);
         }
         dynamicConnectionPorts.Insert(index, port);
         ConnectionPortManager.UpdateRepresentativePortLists(this);
         return(port);
     }
     return(null);
 }
Exemple #4
0
 public ConnectionPortDeclaration(FieldInfo field, ConnectionPortAttribute attr)
 {
     portField = field;
     portInfo  = attr;
 }