예제 #1
0
        // TODO: save the position and zoom in the graph asset
        // public override void OnPersistentDataReady()
        // {
        //  //We set the position and scale saved in the graph asset file
        //  Vector3 pos = graph.position;
        //  Vector3 scale = graph.scale;

        //  base.OnPersistentDataReady();

        //  UpdateViewTransform(pos, scale);
        // }

        public override List <Port> GetCompatiblePorts(Port startPort, NodeAdapter nodeAdapter)
        {
            var compatiblePorts = new List <Port>();

            compatiblePorts.AddRange(ports.ToList().Where(p => {
                var portView = p as PortView;

                if (p.direction == startPort.direction)
                {
                    return(false);
                }

                //Check if there is custom adapters for this assignation
                if (CustomPortIO.IsAssignable(startPort.portType, p.portType))
                {
                    return(true);
                }

                //Check for type assignability
                if (!p.portType.IsReallyAssignableFrom(startPort.portType))
                {
                    return(false);
                }

                //Check if the edge already exists
                if (portView.GetEdges().Any(e => e.input == startPort || e.output == startPort))
                {
                    return(false);
                }

                return(true);
            }));

            return(compatiblePorts);
        }
예제 #2
0
        public NodePort(BaseNode owner, string fieldName)
        {
            this.fieldName = fieldName;
            this.owner     = owner;

            ourValueField = owner.GetType().GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            customPortIOMethod = CustomPortIO.GetCustomPortMethod(owner.GetType(), fieldName);
        }
예제 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="owner">owner node</param>
        /// <param name="fieldName">the C# property name</param>
        /// <param name="portData">Data of the port</param>
        public NodePort(BaseNode owner, string fieldName, PortData portData)
        {
            this.fieldName = fieldName;
            this.owner     = owner;
            this.portData  = portData;

            fieldInfo = owner.GetType().GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            customPortIOMethod = CustomPortIO.GetCustomPortMethod(owner.GetType(), fieldName);
        }