Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -94,6 +94,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]

## [7.1.1] - 2019-09-05
### Added
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
18 changes: 8 additions & 10 deletions com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,14 +787,11 @@ void AddNode(AbstractMaterialNode node)
if (m_SearchWindowProvider.nodeNeedsRepositioning && m_SearchWindowProvider.targetSlotReference.nodeGuid.Equals(node.guid))
{
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 @@ -897,10 +894,11 @@ Edge AddEdge(IEdge edge)
var sourceNodeView = m_GraphView.nodes.ToList().OfType<IShaderNodeView>().FirstOrDefault(x => x.node == sourceNode);
if (sourceNodeView != null)
{
var sourceAnchor = sourceNodeView.gvNode.outputContainer.Children().OfType<ShaderPort>().First(x => x.slot.Equals(sourceSlot));
sourceNodeView.FindPort(sourceSlot.slotReference, out var sourceAnchor);

var 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 @@ -969,7 +967,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