Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.shadergraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed a bug where instanced shaders wouldn't compile on PS4.
- Optimized loading a large Shader Graph. [1209047](https://issuetracker.unity3d.com/issues/shader-graph-unresponsive-editor-when-using-large-graphs)
- Fixed NaN issue in triplanar SG node when blend goes to 0.
- Fixed a recurring bug where node inputs would get misaligned from their ports. [1224480]
- Fixed an issue where Blackboard properties would not duplicate with `Precision` or `Hybrid Instancing` options.
- Fixed an issue where `Texture` properties on the Blackboard would not duplicate with the same `Mode` settings.
- Fixed an issue where `Keywords` on the Blackboard would not duplicate with the same `Default` value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public void OnModified(ModificationScope scope)
}
}

public bool FindPort(SlotReference slot, out ShaderPort port)
{
port = contentContainer.Q("top")?.Query<ShaderPort>().Where(p => p.slot.slotReference.Equals(slot)).First();
return port != null;
}

public void AttachMessage(string errString, ShaderCompilerMessageSeverity severity)
{
ClearMessage();
Expand Down
17 changes: 7 additions & 10 deletions com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -814,14 +814,11 @@ void AddNode(AbstractMaterialNode node, bool usePrebuiltVisualGroupMap = false)
m_SearchWindowProvider.targetSlotReference.node == node)
{
m_SearchWindowProvider.nodeNeedsRepositioning = false;
foreach (var element in nodeView.inputContainer.Children().Union(nodeView.outputContainer.Children()))
if (nodeView is IShaderNodeView shaderView &&
shaderView.FindPort(m_SearchWindowProvider.targetSlotReference, out var port))
{
var port = (ShaderPort) element;
if (port.slot.slotReference.Equals(m_SearchWindowProvider.targetSlotReference))
{
port.RegisterCallback<GeometryChangedEvent>(RepositionNode);
return;
}
port.RegisterCallback<GeometryChangedEvent>(RepositionNode);
return;
}
}

Expand Down Expand Up @@ -1005,15 +1002,15 @@ Edge AddEdge(IEdge edge, bool useVisualNodeMap = false, bool updateNodePorts = t

if (sourceNodeView != null)
{
var sourceAnchor = sourceNodeView.gvNode.outputContainer.Children().OfType<ShaderPort>().First(x => x.slot.Equals(sourceSlot));
sourceNodeView.FindPort(sourceSlot.slotReference, out var sourceAnchor);

IShaderNodeView targetNodeView;
if (useVisualNodeMap)
visualNodeMap.TryGetValue(targetNode, out targetNodeView);
else
targetNodeView = m_GraphView.nodes.ToList().OfType<IShaderNodeView>().First(x => x.node == targetNode);

var targetAnchor = targetNodeView.gvNode.inputContainer.Children().OfType<ShaderPort>().First(x => x.slot.Equals(targetSlot));
targetNodeView.FindPort(targetSlot.slotReference, out var targetAnchor);

var edgeView = new Edge
{
Expand Down Expand Up @@ -1086,7 +1083,7 @@ void UpdateEdgeColors(HashSet<IShaderNodeView> nodeViews)
}
}

foreach (var anchorView in nodeView.inputContainer.Children().OfType<Port>())
foreach (var anchorView in nodeView.inputContainer.Query<Port>().ToList())
{
var targetSlot = anchorView.GetSlot();
if (targetSlot.valueType != SlotValueType.DynamicVector)
Expand Down
4 changes: 4 additions & 0 deletions com.unity.shadergraph/Editor/Drawing/Views/IShaderNodeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEditor.Experimental.GraphView;
using UnityEditor.Graphing;
using UnityEditor.Rendering;
using UnityEditor.ShaderGraph.Drawing;
using UnityEngine;
using UnityEngine.UIElements;

Expand All @@ -18,5 +19,8 @@ interface IShaderNodeView : IDisposable
void OnModified(ModificationScope scope);
void AttachMessage(string errString, ShaderCompilerMessageSeverity severity);
void ClearMessage();
// Searches the ports on this node for one that matches the given slot.
// Returns true if found, false if not.
bool FindPort(SlotReference slot, out ShaderPort port);
}
}
Loading