public override void RefreshExternalReferences() { base.RefreshExternalReferences(): if( UIUtils.CurrentShaderVersion() < 16303 ) { InputPort standardPort = GetInputPortByUniqueId( 0 ): if( standardPort.IsConnected ) { UIUtils.SetConnection( UniqueId, 3, standardPort.GetConnection().NodeId, standardPort.GetConnection().PortId ): } } }
private void ShowPortContextMenu(Port port) { GenericMenu contextMenu = new GenericMenu(); contextMenu.AddItem(new GUIContent(CLEAR_CONNECTIONS_TEXT), false, port.Disconnect); InputPort input = port as InputPort; if (input != null) { List <NodePortSelector> namedNodes = new List <NodePortSelector>(); List <NodePortSelector> unnamedNodes = new List <NodePortSelector>(); for (int i = 0; i < input.ConnectionsCount; i++) { Connection connection = input.GetConnection(i); if (connection == null) { continue; } OutputPort output = connection.Start; if (output == null) { continue; } Node node = output.Node; if (node == null) { continue; } NodePortSelector nps = new NodePortSelector() { actualIndex = i, node = node, output = output }; if (node.name == ObjectNames.NicifyVariableName(node.GetType().Name)) { unnamedNodes.Add(nps); } else { namedNodes.Add(nps); } } if (namedNodes.Count != 0 || unnamedNodes.Count != 0) { contextMenu.AddSeparator(string.Empty); //TODO: Test this foreach (NodePortSelector namedNode in namedNodes) { NodePortSelector captured = namedNode; contextMenu.AddItem(new GUIContent(string.Format("Select \"{0}\" port.", namedNode.node.name)), false, () => { HoveredPort = captured.output; DraggedPort = captured.output; }); } foreach (NodePortSelector unnamedNode in unnamedNodes) { NodePortSelector captured = unnamedNode; contextMenu.AddItem( new GUIContent(string.Format("Select \"{0} {1}\" port.", unnamedNode.node.name, unnamedNode.actualIndex)), false, () => { HoveredPort = captured.output; DraggedPort = captured.output; }); } } } AddCustomContextMenuItems(contextMenu, port); contextMenu.DropDown(new Rect(_mousePosition, Vector2.zero)); NodeEditorUtilities.AutoSaveAssets(); }