浏览代码

Slots can now be changed while a graph is loaded

Rather than storing all sub draw data instances mixed together in a
shared list, they are now stored per type such that e.g. anchors/slots
can easily be updated.
/main
Peter Bay Bastian 8 年前
当前提交
31965b77
共有 1 个文件被更改,包括 32 次插入11 次删除
  1. 43
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/NodeDrawData.cs

43
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/NodeDrawData.cs


using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.Graphing;
using System.Linq;
namespace UnityEditor.Graphing.Drawing
{

public bool expanded = true;
[SerializeField]
[SerializeField]
protected List<AnchorDrawData> m_Anchors = new List<AnchorDrawData>();
[SerializeField]
protected List<GraphElementData> m_Controls = new List<GraphElementData>();
get { return m_Children; }
get { return m_Children.Concat(m_Anchors.Cast<GraphElementData>()).Concat(m_Controls); }
if (scope == ModificationScope.Topological)
{
var slots = node.GetSlots<ISlot>().ToList();
m_Anchors.RemoveAll(data => !slots.Contains(data.slot));
AddSlots(slots.Except(m_Anchors.Select(x => x.slot)));
m_Anchors.Sort((x, y) => slots.IndexOf(x.slot) - slots.IndexOf(y.slot));
}
}
public void CommitChanges()

return new ControlDrawData[0];
}
protected void AddSlots(IEnumerable<ISlot> slots)
{
foreach (var input in slots)
{
var data = CreateInstance<AnchorDrawData>();
data.Initialize(input);
m_Anchors.Add(data);
}
}
public virtual void Initialize(INode inNode)
{
node = inNode;

name = inNode.name;
expanded = node.drawState.expanded;
var m_HeaderData = CreateInstance<HeaderDrawData>();
m_HeaderData.Initialize(inNode);
m_Children.Add(m_HeaderData);
var headerData = CreateInstance<HeaderDrawData>();
headerData.Initialize(inNode);
m_Children.Add(headerData);
foreach (var input in node.GetSlots<ISlot>())
{
var data = CreateInstance<AnchorDrawData>();
data.Initialize(input);
m_Children.Add(data);
}
AddSlots(node.GetSlots<ISlot>());
m_Children.AddRange(controlData);
m_Controls.AddRange(controlData);
position = new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0);
//position

正在加载...
取消
保存