浏览代码

[Material Graph] Tidy view + fix css + add time update nodes in again.

/main
Tim Cooper 8 年前
当前提交
2ea489dd
共有 18 个文件被更改,包括 160 次插入29 次删除
  1. 11
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs
  2. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/NodeDrawer.cs
  3. 5
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializableGraphView.cs
  4. 2
      MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/NodalView.cs
  5. 2
      MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/SimpleContentView.cs
  6. 2
      MaterialGraphProject/Assets/NewUI/Editor/Views/GraphView.cs
  7. 45
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/MaterialNodeDrawer.cs
  8. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphView.cs
  9. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles.meta
  10. 43
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/SerializableGraph.uss
  11. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/SerializableGraph.uss.meta
  12. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles/MaterialGraph.uss
  13. 8
      MaterialGraphProject/Assets/New Shader Graph.ShaderGraph.meta
  14. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles.meta
  15. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles/MaterialGraph.uss.meta

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


using System.Collections.Generic;
using System.Linq;
using RMGUI.GraphView;
using UnityEditor.MaterialGraph.Drawing;
using UnityEngine;
using UnityEngine.Graphing;

NodeUtils.CollectNodesNodeFeedsInto(dependentNodes, inNode);
foreach (var node in dependentNodes)
{
var theElements = m_Elements.OfType<MaterialNodeDrawData>().ToList();
var theElements = m_Elements.OfType<NodeDrawData>().ToList();
var found = theElements.Where(x => x.node.guid == node.guid).ToList();
foreach (var drawableNodeData in found)
drawableNodeData.MarkDirtyHack();

{
m_Elements.Clear();
var drawableNodes = new List<MaterialNodeDrawData>();
var drawableNodes = new List<NodeDrawData>();
foreach (var node in graphAsset.graph.GetNodes<INode>())
{
var type = node.GetType();

type = type.BaseType;
}
if (found == null)
found = typeof(MaterialNodeDrawData);
found = typeof(NodeDrawData);
var nodeData = (MaterialNodeDrawData)CreateInstance(found);
var nodeData = (NodeDrawData)CreateInstance(found);
node.onModified += OnNodeChanged;

UpdateData();
}
public void RemoveElements(IEnumerable<MaterialNodeDrawData> nodes, IEnumerable<EdgeDrawData> edges)
public void RemoveElements(IEnumerable<NodeDrawData> nodes, IEnumerable<EdgeDrawData> edges)
{
graphAsset.graph.RemoveElements(nodes.Select(x => x.node), edges.Select(x => x.edge));
graphAsset.graph.ValidateGraph();

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Drawer/NodeDrawer.cs


using System.Linq;
using RMGUI.GraphView;
using RMGUI.GraphView.Demo;
using UnityEditor.MaterialGraph.Drawing;
using UnityEngine;
using UnityEngine.RMGUI;

name = "controls", // for USS&Flexbox
pickingMode = PickingMode.Ignore,
};
AddToClassList("NodeDrawer");
}
public override void DoRepaint(PaintContext painter)

}
}
private void AddSlots(MaterialNodeDrawData nodeData)
private void AddSlots(NodeDrawData nodeData)
{
m_SlotContainer.ClearChildren();

AddChild(m_SlotContainer);
}
private void AddControls(MaterialNodeDrawData nodeData)
private void AddControls(NodeDrawData nodeData)
{
m_ControlsContainer.ClearChildren();

m_ControlsContainer.ClearChildren();
var nodeData = dataProvider as MaterialNodeDrawData;
var nodeData = dataProvider as NodeDrawData;
if (nodeData == null)
return;

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


using System.Linq;
using RMGUI.GraphView;
using RMGUI.GraphView.Demo;
using UnityEditor.MaterialGraph.Drawing;
[StyleSheet("Assets/UnityShaderEditor/Editor/Styles/NodalView.uss")]
[StyleSheet("Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/SerializableGraph.uss")]
public class SerializableGraphView : GraphView
{
public SerializableGraphView()

return EventPropagation.Stop;
nodalViewData.RemoveElements(
selection.OfType<MaterialNodeDrawer>().Select(x => x.dataProvider as MaterialNodeDrawData),
selection.OfType<NodeDrawer>().Select(x => x.dataProvider as NodeDrawData),
selection.OfType<RMGUI.GraphView.Edge>().Select(x => x.dataProvider as EdgeDrawData)
);

2
MaterialGraphProject/Assets/NewUI/Editor/Demo/Views/NodalView.cs


namespace RMGUI.GraphView.Demo
{
[StyleSheet("Assets/Editor/Demo/Views/NodalView.uss")]
[StyleSheet("Assets/NewUI/Editor/Demo/Views/NodalView.uss")]
class NodesContentView : SimpleContentView
{
private readonly System.Random rnd = new System.Random();

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


namespace RMGUI.GraphView.Demo
{
[StyleSheet("Assets/Editor/Demo/Views/SimpleContentView.uss")]
[StyleSheet("Assets/NewUI/Editor/Demo/Views/SimpleContentView.uss")]
public class SimpleContentView : GraphView
{
public SimpleContentView()

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


namespace RMGUI.GraphView
{
[StyleSheet("Assets/Editor/Views/GraphView.uss")]
[StyleSheet("Assets/NewUI/Editor/Views/GraphView.uss")]
public abstract class GraphView : DataWatchContainer, ISelection
{
private IGraphElementDataSource m_DataSource;

45
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Drawer/MaterialNodeDrawer.cs


using System.Linq;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
using UnityEngine.RMGUI;
namespace UnityEditor.MaterialGraph.Drawing

{
VisualContainer m_PreviewContainer;
private List<NodePreviewDrawData> m_currentPreviewData;
bool m_IsScheduled;
public MaterialNodeDrawer()
{

};
m_currentPreviewData = new List<NodePreviewDrawData>();
onEnter += SchedulePolling;
onLeave += UnschedulePolling;
}
private void SchedulePolling()
{
if (panel != null)
{
if (!m_IsScheduled)
{
this.Schedule(InvalidateUIIfNeedsTime).StartingIn(0).Every(30);
m_IsScheduled = true;
}
}
else
{
m_IsScheduled = false;
}
}
private void UnschedulePolling()
{
if (m_IsScheduled && panel != null)
{
this.Unschedule(InvalidateUIIfNeedsTime);
}
m_IsScheduled = false;
}
private void InvalidateUIIfNeedsTime(TimerState timerState)
{
var childrenNodes = ListPool<INode>.Get();
var data = GetData<MaterialNodeDrawData>();
NodeUtils.DepthFirstCollectNodesFromNode(childrenNodes, data.node);
if (childrenNodes.OfType<IRequiresTime>().Any())
data.MarkDirtyHack();
ListPool<INode>.Release(childrenNodes);
}
private void AddPreview(MaterialNodeDrawData nodeData)

return;
AddPreview(nodeData);
/*positionType = PositionType.Absolute;
positionLeft = nodeData.node.drawState.position.x;
positionTop = nodeData.node.drawState.position.y;*/
}
}
}

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


namespace UnityEditor.MaterialGraph.Drawing
{
[StyleSheet("Assets/UnityShaderEditor/Editor/Styles/NodalView.uss")]
[StyleSheet("Assets/UnityShaderEditor/Editor/Drawing/Styles/MaterialGraph.uss")]
public class MaterialGraphView : SerializableGraphView
{
public MaterialGraphView()

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles.meta


fileFormatVersion: 2
guid: 0bfdedf8c1122ce43a248236ef367ab3
folderAsset: yes
timeCreated: 1476713799
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

43
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Styles/SerializableGraph.uss


NodeDrawer {
flex-direction: column;
}
NodeDrawer #slots {
flex-direction: row;
}
NodeDrawer #slots #input {
flex:1;
flex-direction: column;
}
NodeDrawer #slots #output {
flex:1;
flex-direction: column;
}
NodeDrawer #controls {
flex-direction: column;
padding-bottom: 2;
}
NodeDrawer #controls #element{
flex-direction: column;
}
NodeDrawer {
height: 26;
}
NodeDrawer #preview {
flex-direction: column;
}
NodeDrawer #preview #image {
height: 200;
width: 200;
}
NodeAnchor {
height: 26;
}

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


fileFormatVersion: 2
guid: 2063531155c6d8f4db408f840d0daed9
timeCreated: 1476713791
licenseType: Pro
StyleSheetImporter:
userData:
assetBundleName:
assetBundleVariant:

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles/MaterialGraph.uss


MaterialNodeDrawer {
flex-direction: column;
}
MaterialNodeDrawer #slots {
flex-direction: row;
}
MaterialNodeDrawer #slots #input {
flex:1;
flex-direction: column;
}
MaterialNodeDrawer #slots #output {
flex:1;
flex-direction: column;
}
MaterialNodeDrawer #controls {
flex-direction: column;
padding-bottom: 2;
}
MaterialNodeDrawer #controls #element{
flex-direction: column;
}
MaterialNodeDrawer {
height: 26;
}
MaterialNodeDrawer #preview {
flex-direction: column;
}
MaterialNodeDrawer #preview #image {
height: 200;
width: 200;
}
NodeAnchor {
height: 26;
}

8
MaterialGraphProject/Assets/New Shader Graph.ShaderGraph.meta


fileFormatVersion: 2
guid: 00792c7fb4484764c9916044dbd747e8
timeCreated: 1472740580
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Styles.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles.meta

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Styles/NodalView.uss.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Styles/MaterialGraph.uss.meta

正在加载...
取消
保存