void DragGraphInput(GraphData graphData) { AssertHelpers.IsNotNull(graphData, "GraphData is null while carrying out DragGraphInputAction"); AssertHelpers.IsNotNull(graphInputBeingDraggedIn, "GraphInputBeingDraggedIn is null while carrying out DragGraphInputAction"); graphData.owner.RegisterCompleteObjectUndo("Drag Graph Input"); switch (graphInputBeingDraggedIn) { case AbstractShaderProperty property: { if (property is MultiJsonInternal.UnknownShaderPropertyType) { break; } // This could be from another graph, in which case we add a copy of the ShaderInput to this graph. if (graphData.properties.FirstOrDefault(p => p == property) == null) { var copyShaderInputAction = new CopyShaderInputAction(); copyShaderInputAction.shaderInputToCopy = property; graphData.owner.graphDataStore.Dispatch(copyShaderInputAction); property = (AbstractShaderProperty)copyShaderInputAction.copiedShaderInput; } var node = new PropertyNode(); var drawState = node.drawState; drawState.position = new Rect(nodePosition, drawState.position.size); node.drawState = drawState; graphData.AddNode(node); // Setting the guid requires the graph to be set first. node.property = property; break; } case ShaderKeyword keyword: { // This could be from another graph, in which case we add a copy of the ShaderInput to this graph. if (graphData.keywords.FirstOrDefault(k => k == keyword) == null) { var copyShaderInputAction = new CopyShaderInputAction(); copyShaderInputAction.shaderInputToCopy = keyword; graphData.owner.graphDataStore.Dispatch(copyShaderInputAction); keyword = (ShaderKeyword)copyShaderInputAction.copiedShaderInput; } var node = new KeywordNode(); var drawState = node.drawState; drawState.position = new Rect(nodePosition, drawState.position.size); node.drawState = drawState; graphData.AddNode(node); // Setting the guid requires the graph to be set first. node.keyword = keyword; break; } case ShaderDropdown dropdown: { if (graphData.IsInputAllowedInGraph(dropdown)) { // This could be from another graph, in which case we add a copy of the ShaderInput to this graph. if (graphData.dropdowns.FirstOrDefault(d => d == dropdown) == null) { var copyShaderInputAction = new CopyShaderInputAction(); copyShaderInputAction.shaderInputToCopy = dropdown; graphData.owner.graphDataStore.Dispatch(copyShaderInputAction); dropdown = (ShaderDropdown)copyShaderInputAction.copiedShaderInput; } var node = new DropdownNode(); var drawState = node.drawState; drawState.position = new Rect(nodePosition, drawState.position.size); node.drawState = drawState; graphData.AddNode(node); // Setting the guid requires the graph to be set first. node.dropdown = dropdown; } break; } default: throw new ArgumentOutOfRangeException(); } }