浏览代码

Fix order of things when adding slots (fixes #111)

/main
Peter Bay Bastian 7 年前
当前提交
02c12a94
共有 1 个文件被更改,包括 16 次插入5 次删除
  1. 21
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs

21
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs


using UnityEngine.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using Node = UnityEditor.Experimental.UIElements.GraphView.Node;
namespace UnityEditor.ShaderGraph.Drawing
{

AddSlots(node.GetSlots<MaterialSlot>());
expanded = node.drawState.expanded;
RefreshExpandedState(); //This should not be needed. GraphView needs to improve the extension api here
UpdateSlotAttachers();
UpdatePortInputVisibilities();
SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0));

UpdateTitle();
if (node.hasPreview)
UpdatePreviewExpandedState(node.previewExpanded);
expanded = node.drawState.expanded;
base.expanded = node.drawState.expanded;
// Update slots to match node modification
if (scope == ModificationScope.Topological)
{

outputContainer.Sort((x, y) => slots.IndexOf(x.userData as MaterialSlot) - slots.IndexOf(y.userData as MaterialSlot));
}
UpdateControls();
RefreshExpandedState(); //This should not be needed. GraphView needs to improve the extension api here
UpdateSlotAttachers();
UpdatePortInputVisibilities();
foreach (var control in m_ControlViews)

port.visualClass = slot.concreteValueType.ToClassName();
if (slot.isOutputSlot)
{
}
inputContainer.Add(port);
}
}
void UpdateSlotAttachers()
{
foreach (var port in inputContainer.OfType<Port>())
{
if (!m_Attachers.Any(a => a.target == port))
inputContainer.Add(port);
var portInputView = new PortInputView(slot);
var portInputView = new PortInputView((MaterialSlot)port.userData);
Add(portInputView);
mainContainer.BringToFront();
m_Attachers.Add(new Attacher(portInputView, port, SpriteAlignment.LeftCenter) { distance = -8f });

正在加载...
取消
保存