public override HandleData Initialize(Node node, BehaviourEntry entry, BehaviourGraphView graphView, BehaviourGraphSettings settings, int index) { var port = Port.Create <Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Single, typeof(BehaviourPort <>).MakeGenericType(settings.BehaviourType)); port.portName = (index >= 0 && index < (entry.Fields?.Length ?? 0)) ? entry.Fields[index].info.fullName : null; port.portColor = settings.BehaviourType.GetColor(); port.AddToClassList(NODE_INDEX_PORT); port.userData = new FieldPortUpdater(entry, index); port.RegisterCallback <AttachToPanelEvent>(evt => { if (evt.target is Port self && !self.connected) { var graphView = self.GetFirstAncestorOfType <BehaviourGraphView>(); if (graphView != null && self.userData is FieldPortUpdater updater && updater.index >= 0 && updater.index < (updater.entry.Fields?.Length ?? 0) && graphView.GetNodeByGuid(updater.entry.Fields[updater.index].data) is Node node) { var inputPort = node.Q <Port>(null, IntermediateEntry.INPUT_PORT); if (inputPort != null) { graphView.AddElement(self.ConnectTo(inputPort)); } } } }); return(new HandleData { element = port, target = NodeTarget.Output }); }
public abstract HandleData Initialize(Node node, BehaviourEntry entry, BehaviourGraphView graphView, BehaviourGraphSettings settings, int index);