浏览代码

Extracted type mapping of AbstractGraphDataSource into own function

/main
Peter Bay Bastian 8 年前
当前提交
a6b9b337
共有 1 个文件被更改,包括 15 次插入14 次删除
  1. 29
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs

29
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs


var drawableNodes = new List<NodeDrawData>();
foreach (var node in graphAsset.graph.GetNodes<INode>())
{
var type = node.GetType();
Type found = null;
while (type != null)
{
if (m_DataMapper.TryGetValue(type, out found))
break;
type = type.BaseType;
}
if (found == null)
found = typeof(NodeDrawData);
var nodeData = (NodeDrawData)CreateInstance(found);
var type = MapType(node.GetType());
var nodeData = (NodeDrawData)CreateInstance(type);
node.onModified += OnNodeChanged;

m_Elements.AddRange(drawableEdges.OfType<GraphElementData>());
}
private Type MapType(Type type)
{
Type found = null;
while (type != null)
{
if (m_DataMapper.TryGetValue(type, out found))
break;
type = type.BaseType;
}
return type ?? typeof(NodeDrawData);
}
protected abstract void AddTypeMappings();
public void AddTypeMapping(Type node, Type drawData)

}
protected AbstractGraphDataSource()
{}
{ }
public void AddNode(INode node)
{

正在加载...
取消
保存