浏览代码

Integrate latest GraphView

Signed-off-by: joce <joce@unity3d.com>
/main
joce 8 年前
当前提交
c5baafe7
共有 13 个文件被更改,包括 43 次插入43 次删除
  1. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs
  2. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs
  3. 8
      MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/NodesContentView.cs
  4. 14
      MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/SimpleContentView.cs
  5. 8
      MaterialGraphProject/Assets/NewUI/Editor/Views/GraphView.cs
  6. 6
      MaterialGraphProject/Assets/NewUI/Editor/BaseTypeMapper.cs
  7. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs
  8. 2
      MaterialGraphProject/ProjectSettings/ProjectVersion.txt
  9. 19
      MaterialGraphProject/Assets/NewUI/Editor/GraphViewTypeMapper.cs
  10. 19
      MaterialGraphProject/Assets/NewUI/Editor/GraphViewDataMapper.cs
  11. 0
      /MaterialGraphProject/Assets/NewUI/Editor/BaseTypeMapper.cs.meta
  12. 0
      /MaterialGraphProject/Assets/NewUI/Editor/GraphViewTypeMapper.cs.meta
  13. 0
      /MaterialGraphProject/Assets/NewUI/Editor/BaseTypeMapper.cs

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs


InsertChild(0, new GridBackground());
dataMapper[typeof(GraphNodePresenter)] = typeof(NodeDrawer);
typeMapper[typeof(GraphNodePresenter)] = typeof(NodeDrawer);
}
// TODO JOCE Remove the "new" here. Use the base class' impl

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs


namespace UnityEditor.Graphing.Util
{
public class TypeMapper : BaseDataMapper<INode, ScriptableObject>
public class TypeMapper : BaseTypeMapper<INode, ScriptableObject>
{
public TypeMapper(Type fallbackType) : base(fallbackType)
{

8
MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/NodesContentView.cs


return EventPropagation.Continue;
}));
dataMapper[typeof(CustomEdgePresenter)] = typeof(CustomEdge);
dataMapper[typeof(NodeAnchorPresenter)] = typeof(NodeAnchor);
dataMapper[typeof(NodePresenter)] = typeof(Node);
dataMapper[typeof(VerticalNodePresenter)] = typeof(Node);
typeMapper[typeof(CustomEdgePresenter)] = typeof(CustomEdge);
typeMapper[typeof(NodeAnchorPresenter)] = typeof(NodeAnchor);
typeMapper[typeof(NodePresenter)] = typeof(Node);
typeMapper[typeof(VerticalNodePresenter)] = typeof(Node);
}
public void CreateOperator()

14
MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/SimpleContentView.cs


InsertChild(0, new GridBackground());
dataMapper[typeof(CirclePresenter)] = typeof(Circle);
dataMapper[typeof(InvisibleBorderContainerPresenter)] = typeof(InvisibleBorderContainer);
dataMapper[typeof(MiniMapPresenter)] = typeof(MiniMap);
dataMapper[typeof(SimpleElementPresenter)] = typeof(SimpleElement);
dataMapper[typeof(WWWImagePresenter)] = typeof(WWWImage);
dataMapper[typeof(IMGUIPresenter)] = typeof(IMGUIElement);
dataMapper[typeof(CommentPresenter)] = typeof(Comment);
typeMapper[typeof(CirclePresenter)] = typeof(Circle);
typeMapper[typeof(InvisibleBorderContainerPresenter)] = typeof(InvisibleBorderContainer);
typeMapper[typeof(MiniMapPresenter)] = typeof(MiniMap);
typeMapper[typeof(SimpleElementPresenter)] = typeof(SimpleElement);
typeMapper[typeof(WWWImagePresenter)] = typeof(WWWImage);
typeMapper[typeof(IMGUIPresenter)] = typeof(IMGUIElement);
typeMapper[typeof(CommentPresenter)] = typeof(Comment);
}
}
}

8
MaterialGraphProject/Assets/NewUI/Editor/Views/GraphView.cs


}
}
protected GraphViewDataMapper dataMapper { get; set; }
protected GraphViewTypeMapper typeMapper { get; set; }
public VisualContainer contentViewContainer{ get; private set; }

// make it absolute and 0 sized so it acts as a transform to move children to and fro
AddChild(contentViewContainer);
dataMapper = new GraphViewDataMapper();
dataMapper[typeof(EdgePresenter)] = typeof(Edge);
typeMapper = new GraphViewTypeMapper();
typeMapper[typeof(EdgePresenter)] = typeof(Edge);
}
public override void OnDataChanged()

private void InstantiateElement(GraphElementPresenter elementPresenter)
{
// call factory
GraphElement newElem = dataMapper.Create(elementPresenter);
GraphElement newElem = typeMapper.Create(elementPresenter);
if (newElem == null)
{

6
MaterialGraphProject/Assets/NewUI/Editor/BaseTypeMapper.cs


namespace RMGUI.GraphView
{
public abstract class BaseDataMapper<TKey, TValue>
public abstract class BaseTypeMapper<TKey, TValue>
{
private readonly Dictionary<Type, Type> m_Mappings = new Dictionary<Type, Type>();
private readonly Type m_FallbackType;

static BaseDataMapper()
static BaseTypeMapper()
{
k_KeyType = typeof(TKey);
k_ValueType = typeof(TValue);

return InternalCreate(valueType);
}
protected BaseDataMapper(Type fallbackType)
protected BaseTypeMapper(Type fallbackType)
{
m_FallbackType = fallbackType;
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs


{
AddManipulator(new ContextualMenu(DoContextMenu));
dataMapper[typeof(MaterialNodePresenter)] = typeof(MaterialNodeDrawer);
dataMapper[typeof(GraphAnchorPresenter)] = typeof(NodeAnchor);
dataMapper[typeof(EdgePresenter)] = typeof(Edge);
typeMapper[typeof(MaterialNodePresenter)] = typeof(MaterialNodeDrawer);
typeMapper[typeof(GraphAnchorPresenter)] = typeof(NodeAnchor);
typeMapper[typeof(EdgePresenter)] = typeof(Edge);
}
public virtual bool CanAddToNodeMenu(Type type)

2
MaterialGraphProject/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 5.6.0a5
m_EditorVersion: 5.6.0b4

19
MaterialGraphProject/Assets/NewUI/Editor/GraphViewTypeMapper.cs


namespace RMGUI.GraphView
{
public class GraphViewTypeMapper : BaseTypeMapper<GraphElementPresenter, GraphElement>
{
public GraphViewTypeMapper() : base(typeof(FallbackGraphElement))
{
}
public override GraphElement Create(GraphElementPresenter key)
{
GraphElement elem = base.Create(key);
if (elem != null)
{
elem.presenter = key;
}
return elem;
}
}
}

19
MaterialGraphProject/Assets/NewUI/Editor/GraphViewDataMapper.cs


namespace RMGUI.GraphView
{
public class GraphViewDataMapper : BaseDataMapper<GraphElementPresenter, GraphElement>
{
public GraphViewDataMapper() : base(typeof(FallbackGraphElement))
{
}
public override GraphElement Create(GraphElementPresenter key)
{
GraphElement elem = base.Create(key);
if (elem != null)
{
elem.presenter = key;
}
return elem;
}
}
}

/MaterialGraphProject/Assets/NewUI/Editor/BaseDataMapper.cs.meta → /MaterialGraphProject/Assets/NewUI/Editor/BaseTypeMapper.cs.meta

/MaterialGraphProject/Assets/NewUI/Editor/GraphViewDataMapper.cs.meta → /MaterialGraphProject/Assets/NewUI/Editor/GraphViewTypeMapper.cs.meta

/MaterialGraphProject/Assets/NewUI/Editor/BaseDataMapper.cs → /MaterialGraphProject/Assets/NewUI/Editor/BaseTypeMapper.cs

正在加载...
取消
保存