浏览代码

Created GraphEditorDrawer by extracting view stuff from AbstractGraphEditWindow

The latter was getting very crowded and more views that are not inside
the GraphView are on the way.
/main
Peter Bay Bastian 8 年前
当前提交
682248e0
共有 7 个文件被更改,包括 103 次插入26 次删除
  1. 6
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs
  2. 20
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs
  3. 61
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/GraphEditorDrawer.cs
  4. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/GraphEditorDrawer.cs.meta
  5. 13
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/GraphEditor.uss
  6. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/GraphEditor.uss.meta
  7. 9
      MaterialGraphProject/Assets/NewUI/Editor/Demo/GraphElements/Graph.meta

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


[SerializeField]
private List<GraphElementData> m_TempElements = new List<GraphElementData>();
[SerializeField]
private TitleBarDrawData m_TitleBar;
[SerializeField]
private TitleBarDrawData m_TitleBar;
public TitleBarDrawData titleBar
{

20
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs


protected GraphView graphView
{
get { return m_GraphView; }
get { return m_GraphEditorDrawer.GraphView; }
private GraphView m_GraphView;
private TitleBarDrawer m_TitleBarDrawer;
private GraphEditorDrawer m_GraphEditorDrawer;
public virtual AbstractGraphDataSource CreateDataSource()
{

void OnEnable()
{
m_GraphView = CreateGraphView();
m_GraphView.name = "Graph View";
m_TitleBarDrawer = new TitleBarDrawer(source.titleBar);
m_GraphView.dataSource = source;
rootVisualContainer.AddChild(m_TitleBarDrawer);
rootVisualContainer.AddChild(m_GraphView);
m_GraphEditorDrawer = new GraphEditorDrawer(CreateGraphView(), source);
rootVisualContainer.AddChild(m_GraphEditorDrawer);
}
void OnDisable()

var source = CreateDataSource();
source.Initialize(m_LastSelection);
m_GraphView.dataSource = source;
m_TitleBarDrawer.dataProvider = source.titleBar;
m_GraphEditorDrawer.dataSource = source;
m_GraphView.StretchToParentSize();
//m_GraphView.StretchToParentSize();
Repaint();
}
}

61
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/GraphEditorDrawer.cs


using System;
using RMGUI.GraphView;
using UnityEngine.RMGUI;
namespace UnityEditor.Graphing.Drawing
{
[StyleSheet("Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/GraphEditor.uss")]
public class GraphEditorDrawer : DataWatchContainer
{
private GraphView m_GraphView;
public GraphView GraphView
{
get { return m_GraphView; }
}
private TitleBarDrawer m_TitleBarDrawer;
// TODO: Create graphView from here rather than have it passed in through constructor
public GraphEditorDrawer(GraphView graphView, AbstractGraphDataSource dataSource)
{
m_GraphView = graphView;
m_GraphView.name = "GraphView";
m_TitleBarDrawer = new TitleBarDrawer(dataSource.titleBar);
m_TitleBarDrawer.name = "TitleBar";
AddChild(m_TitleBarDrawer);
AddChild(m_GraphView);
this.dataSource = dataSource;
}
public override void OnDataChanged()
{
m_GraphView.dataSource = m_DataSource;
m_TitleBarDrawer.dataProvider = m_DataSource.titleBar;
}
private AbstractGraphDataSource m_DataSource;
public AbstractGraphDataSource dataSource
{
get { return m_DataSource; }
set
{
if (m_DataSource == value)
return;
RemoveWatch();
m_DataSource = value;
OnDataChanged();
AddWatch();
}
}
protected override object toWatch
{
get { return m_DataSource; }
}
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/GraphEditorDrawer.cs.meta


fileFormatVersion: 2
guid: 39a37c8d2156b41e182286e521fe51f4
timeCreated: 1481279276
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

13
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/GraphEditor.uss


GraphEditorDrawer {
flex-direction: column;
background: #f00;
flex: 1;
}
GraphEditorDrawer #TitleBar {
}
GraphEditorDrawer #GraphView {
flex: 1;
}

8
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/GraphEditor.uss.meta


fileFormatVersion: 2
guid: ae648c9eacf7c4a71996da830fc36acf
timeCreated: 1481280685
licenseType: Pro
StyleSheetImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/NewUI/Editor/Demo/GraphElements/Graph.meta


fileFormatVersion: 2
guid: f22bdd0720b76fb49a1a7d2461de982b
folderAsset: yes
timeCreated: 1475171334
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存