예제 #1
0
 public bool IsCompatibleWith(NodeSlot otherSlot)
 {
     return(otherSlot != null &&
            otherSlot.owner != owner &&
            otherSlot.isInputSlot != isInputSlot &&
            otherSlot.isOutputSlot != isOutputSlot &&
            (otherSlot.valueType == valueType || otherSlot.valueType.Type.IsAssignableFrom(valueType)));
 }
        public void ValidateGraph()
        {
            var propertyNodes = GetNodes <PropertyNode>().Where(n => !m_Properties.Any(p => p.guid == n.propertyGuid)).ToArray();

            foreach (var pNode in propertyNodes)
            {
                ReplacePropertyNodeWithConcreteNodeNoValidate(pNode);
            }

            //First validate edges, remove any
            //orphans. This can happen if a user
            //manually modifies serialized data
            //of if they delete a node in the inspector
            //debug view.
            foreach (var edge in m_Edges.ToArray())
            {
                var outputNode = GetNodeFromGuid(edge.outputSlot.nodeGuid);
                var inputNode  = GetNodeFromGuid(edge.inputSlot.nodeGuid);

                NodeSlot outputSlot = null;
                NodeSlot inputSlot  = null;
                if (outputNode != null && inputNode != null)
                {
                    outputSlot = outputNode.FindOutputSlot <NodeSlot>(edge.outputSlot.slotId);
                    inputSlot  = inputNode.FindInputSlot <NodeSlot>(edge.inputSlot.slotId);
                }

                if (outputNode == null ||
                    inputNode == null ||
                    outputSlot == null ||
                    inputSlot == null ||
                    !outputSlot.IsCompatibleWith(inputSlot))
                {
                    //orphaned edge
                    RemoveEdgeNoValidate(edge);
                }
            }

            foreach (var node in GetNodes <INode>())
            {
                node.ValidateNode();
            }

            foreach (var edge in m_AddedEdges.ToList())
            {
                if (!ContainsNodeGuid(edge.outputSlot.nodeGuid) || !ContainsNodeGuid(edge.inputSlot.nodeGuid))
                {
                    Debug.LogWarningFormat("Added edge is invalid: {0} -> {1}\n{2}", edge.outputSlot.nodeGuid, edge.inputSlot.nodeGuid, Environment.StackTrace);
                    m_AddedEdges.Remove(edge);
                }
            }
        }
예제 #3
0
 bool Equals(NodeSlot other)
 {
     return(m_Id == other.m_Id && owner.guid.Equals(other.owner.guid));
 }
예제 #4
0
 public abstract void CopyValuesFrom(NodeSlot foundSlot);
예제 #5
0
 public override void CopyValuesFrom(NodeSlot foundSlot)
 {
 }