浏览代码

Implemented basic title bar

/main
Peter Bay Bastian 8 年前
当前提交
af616546
共有 10 个文件被更改,包括 160 次插入8 次删除
  1. 13
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs
  2. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/NodeDrawData.cs
  3. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/SerializableGraph.uss.imported.asset.meta
  4. 12
      MaterialGraphProject/Assets/NewUI/Editor/Views/GraphView.uss
  5. 14
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarDrawData.cs
  6. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarDrawData.cs.meta
  7. 72
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/TitleBarDrawer.cs
  8. 12
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/TitleBarDrawer.cs.meta
  9. 21
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/TitleBar.uss
  10. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/TitleBar.uss.meta

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


private GraphView m_GraphView;
private TitleBarDrawer m_TitleBarDrawer;
public virtual AbstractGraphDataSource CreateDataSource()
{
return CreateInstance<SerializedGraphDataSource>();

m_GraphView.name = "Graph View";
var source = CreateDataSource();
source.Initialize(m_LastSelection);
var titleBarData = CreateInstance<TitleBarDrawData>();
titleBarData.title = m_LastSelection != null ? m_LastSelection.GetScriptableObject().name : "";
m_TitleBarDrawer = new TitleBarDrawer(titleBarData);
windowRoot.AddChild(m_TitleBarDrawer);
windowRoot.AddChild(m_GraphView);
}

graph.ValidateGraph();
m_LastSelection = selection;
var titleBarData = CreateInstance<TitleBarDrawData>();
titleBarData.title = m_LastSelection != null ? m_LastSelection.GetScriptableObject().name : "";
m_TitleBarDrawer.dataProvider = titleBarData;
m_GraphView.StretchToParentSize();
Repaint();

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


public INode node { get; private set; }
[SerializeField] public bool expanded = true;
public bool expanded = true;
protected List<GraphElementData> m_Children = new List<GraphElementData>();

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/SerializableGraph.uss.imported.asset.meta


fileFormatVersion: 2
guid: 692fd89d176246745ad1640285f640d1
timeCreated: 1478599791
timeCreated: 1479153323
licenseType: Pro
NativeFormatImporter:
userData:

12
MaterialGraphProject/Assets/NewUI/Editor/Views/GraphView.uss


/* this class is added to all graphElement instances*/
.graphElement {
text-alignment:upper-center;
text-color:#FFF;
text-alignment: upper-center;
text-color: #FFF;
border-left:2;
border-top:2;
border-right:2;
border-bottom:2;
border-left: 2;
border-top: 2;
border-right: 2;
border-bottom: 2;
border-width: 2;
border-radius: 5;
background-color: #333;

14
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarDrawData.cs


using RMGUI.GraphView;
using UnityEngine;
namespace UnityEditor.Graphing.Drawing
{
public class TitleBarDrawData : ScriptableObject
{
protected TitleBarDrawData()
{
}
public string title;
}
}

12
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/DrawData/TitleBarDrawData.cs.meta


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

72
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/TitleBarDrawer.cs


using System;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.RMGUI;
using UnityEngine.RMGUI.StyleEnums;
using UnityEngine.RMGUI.StyleSheets;
namespace UnityEditor.Graphing.Drawing
{
[StyleSheet("Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/TitleBar.uss")]
public class TitleBarDrawer : DataWatchContainer
{
private TitleBarDrawData m_dataProvider;
private Label m_title;
public TitleBarDrawData dataProvider
{
get { return m_dataProvider; }
set
{
if (m_dataProvider == value)
return;
RemoveWatch();
m_dataProvider = value;
OnDataChanged();
AddWatch();
}
}
public TitleBarDrawer(TitleBarDrawData dataProvider)
{
classList = ClassList.empty;
name = "TitleBar";
zBias = 99;
var leftContainer = new VisualContainer()
{
name = "left"
};
AddChild(leftContainer);
var rightContainer = new VisualContainer()
{
name = "right"
};
AddChild(rightContainer);
m_title = new Label(new GUIContent("testttt"))
{
name = "title",
};
leftContainer.AddChild(m_title);
this.dataProvider = dataProvider;
}
public override void OnDataChanged()
{
if (m_dataProvider == null)
return;
m_title.content.text = m_dataProvider.title;
this.Touch(ChangeType.Repaint);
}
protected override object toWatch
{
get { return dataProvider; }
}
}
}

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


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

21
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/TitleBar.uss


#TitleBar {
position-type: absolute;
position-left: 0;
position-right: 0;
position-top: 0;
flex-direction: row;
justify-content: space-between;
align-items: stretch;
background-color: #333;
}
#TitleBar #left {
/* background-color: #f00; */
align-items: center;
flex-direction: row;
}
#TitleBar #left #title {
background-color: #f00;
font-size: 12;
}

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


fileFormatVersion: 2
guid: 2bdb46d80eb734cc2bc61fa6a2302e52
timeCreated: 1479148211
licenseType: Pro
StyleSheetImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存