浏览代码

Purge usage of presenters and datawatch from graph inspector

/main
Peter Bay Bastian 7 年前
当前提交
64c9a49b
共有 18 个文件被更改,包括 205 次插入350 次删除
  1. 44
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  2. 76
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/GraphInspectorPresenter.cs
  3. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/AbstractNodeEditorView.cs
  4. 70
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/GraphInspectorView.cs
  5. 107
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/IMGUISlotEditorView.cs
  6. 53
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/StandardNodeEditorView.cs
  7. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/SurfaceMasterNodeEditorView.cs
  8. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphEditorPresenter.cs
  9. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  10. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/UIUtilities.cs
  11. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/AbstractNodeEditorPresenter.cs.meta
  12. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/IMGUISlotEditorPresenter.cs
  13. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/IMGUISlotEditorPresenter.cs.meta
  14. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/StandardNodeEditorPresenter.cs.meta
  15. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/SurfaceMasterNodeEditorPresenter.cs.meta
  16. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/AbstractNodeEditorPresenter.cs
  17. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/StandardNodeEditorPresenter.cs
  18. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/SurfaceMasterNodeEditorPresenter.cs

44
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


GraphEditorView m_GraphEditorView;
GraphEditorView graphEditorView
{
get { return m_GraphEditorView; }
set
{
if (m_GraphEditorView != null)
m_GraphEditorView.Dispose();
m_GraphEditorView = value;
}
}
public TGraphType inMemoryAsset
{
get { return m_InMemoryAsset; }

void Update()
{
if (m_GraphEditorView != null)
if (graphEditorView != null)
if (m_GraphEditorView.presenter == null)
if (graphEditorView.presenter == null)
m_GraphEditorView.presenter.graphPresenter.UpdateTimeDependentNodes();
graphEditorView.presenter.graphPresenter.UpdateTimeDependentNodes();
m_GraphEditorView = new GraphEditorView();
rootVisualContainer.Add(m_GraphEditorView);
graphEditorView = new GraphEditorView();
rootVisualContainer.Add(graphEditorView);
}
void OnDisable()

{
UpdateAsset();
}
graphEditorView.Dispose();
var presenter = m_GraphEditorView.presenter;
var presenter = graphEditorView.presenter;
var e = Event.current;
if (e.type == EventType.ValidateCommand && (

if (e.type == EventType.KeyDown)
{
if (e.keyCode == KeyCode.A)
m_GraphEditorView.graphView.FrameAll();
graphEditorView.graphView.FrameAll();
m_GraphEditorView.graphView.FrameSelection();
graphEditorView.graphView.FrameSelection();
m_GraphEditorView.graphView.FrameOrigin();
graphEditorView.graphView.FrameOrigin();
m_GraphEditorView.graphView.FrameNext();
graphEditorView.graphView.FrameNext();
m_GraphEditorView.graphView.FramePrev();
graphEditorView.graphView.FramePrev();
}
}

if (path.Length == 0)
return;
var graphPresenter = m_GraphEditorView.presenter.graphPresenter;
var graphPresenter = graphEditorView.presenter.graphPresenter;
var selected = graphPresenter.elements.Where(e => e.selected).ToArray();
var deserialized = MaterialGraphPresenter.DeserializeCopyBuffer(JsonUtility.ToJson(MaterialGraphPresenter.CreateCopyPasteGraph(selected)));

{
var presenter = CreateInstance<GraphEditorPresenter>();
presenter.Initialize(inMemoryAsset, this, selected.name);
m_GraphEditorView.presenter = presenter;
m_GraphEditorView.RegisterCallback<PostLayoutEvent>(OnPostLayout);
graphEditorView.presenter = presenter;
graphEditorView.RegisterCallback<PostLayoutEvent>(OnPostLayout);
m_GraphEditorView.UnregisterCallback<PostLayoutEvent>(OnPostLayout);
m_GraphEditorView.graphView.FrameAll();
graphEditorView.UnregisterCallback<PostLayoutEvent>(OnPostLayout);
graphEditorView.graphView.FrameAll();
}
}
}

76
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/GraphInspectorPresenter.cs


using System;
using System.Linq;
using UnityEditor.Graphing.Util;
using UnityEditor.MaterialGraph.Drawing.Inspector;
using UnityEngine.MaterialGraph;
[SerializeField]
AbstractNodeEditorPresenter m_Editor;
public IGraph graph { get; set; }
[SerializeField]
string m_Title;
public string assetName { get; set; }
[SerializeField]
int m_SelectionCount;
public List<INode> selectedNodes { get; set; }
TypeMapper m_TypeMapper;
public AbstractNodeEditorPresenter editor
[Flags]
public enum ChangeType
get { return m_Editor; }
Graph = 1 << 0,
SelectedNodes = 1 << 1,
AssetName = 1 << 2,
All = -1
public string title
{
get { return m_Title; }
set { m_Title = value; }
}
public delegate void OnChange(ChangeType changeType);
public int selectionCount
{
get { return m_SelectionCount; }
set { m_SelectionCount = value; }
}
public OnChange onChange;
public void Initialize(string graphName)
public void Initialize(string assetName, IGraph graph)
m_Title = graphName;
m_TypeMapper = new TypeMapper(typeof(INode), typeof(AbstractNodeEditorPresenter), typeof(StandardNodeEditorPresenter))
{
{typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorPresenter)}
};
// Nodes missing custom editors:
// - PropertyNode
// - SubGraphInputNode
// - SubGraphOutputNode
this.graph = graph;
this.assetName = assetName;
selectedNodes = new List<INode>();
if (onChange != null)
onChange(ChangeType.Graph | ChangeType.SelectedNodes | ChangeType.AssetName);
using (var nodesList = ListPool<INode>.GetDisposable())
{
nodesList.value.AddRange(nodes);
m_SelectionCount = nodesList.value.Count;
selectedNodes.Clear();
selectedNodes.AddRange(nodes);
if (m_SelectionCount == 1)
{
var node = nodesList.value.First();
if (m_Editor == null || node != m_Editor.node)
{
m_Editor = (AbstractNodeEditorPresenter) CreateInstance(m_TypeMapper.MapType(node.GetType()));
m_Editor.node = node;
}
}
else
{
m_Editor = null;
}
}
if (onChange != null)
onChange(ChangeType.SelectedNodes);
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/AbstractNodeEditorView.cs


using UnityEditor.Experimental.UIElements.GraphView;
using System;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Graphing;
public class AbstractNodeEditorView : DataWatchContainer
public abstract class AbstractNodeEditorView : VisualElement, IDisposable
[SerializeField]
AbstractNodeEditorPresenter m_Presenter;
public abstract INode node { get; set; }
public AbstractNodeEditorPresenter presenter
{
get { return m_Presenter; }
set
{
if (value == m_Presenter)
return;
RemoveWatch();
m_Presenter = value;
m_ToWatch[0] = m_Presenter;
OnDataChanged();
AddWatch();
}
}
Object[] m_ToWatch = { null };
protected override Object[] toWatch
{
get { return m_ToWatch; }
}
public abstract void Dispose();
}
}

70
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/GraphInspectorView.cs


using System;
using System.Linq;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
public class GraphInspectorView : DataWatchContainer
public class GraphInspectorView : VisualElement, IDisposable
int m_PresenterHash;
int m_SelectionHash;
VisualElement m_MultipleSelectionsElement;
AbstractNodeEditorView m_EditorView;
TypeMapper m_TypeMapper;

m_ContentContainer = new VisualElement { name = "contentContainer" };
Add(m_ContentContainer);
m_TypeMapper = new TypeMapper(typeof(AbstractNodeEditorPresenter), typeof(AbstractNodeEditorView))
// Nodes missing custom editors:
// - PropertyNode
// - SubGraphInputNode
// - SubGraphOutputNode
m_TypeMapper = new TypeMapper(typeof(INode), typeof(AbstractNodeEditorView), typeof(StandardNodeEditorView))
{ typeof(StandardNodeEditorPresenter), typeof(StandardNodeEditorView) },
{ typeof(SurfaceMasterNodeEditorPresenter), typeof(SurfaceMasterNodeEditorView) }
{ typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorView) }
public override void OnDataChanged()
public void OnChange(GraphInspectorPresenter.ChangeType changeType)
m_PresenterHash = 0;
m_SelectionHash = 0;
var presenterHash = UIUtilities.GetHashCode(presenter.editor, presenter.selectionCount);
if ((changeType & GraphInspectorPresenter.ChangeType.AssetName) != 0)
m_Title.text = presenter.assetName;
m_Title.text = presenter.title;
if (presenterHash != m_PresenterHash)
if ((changeType & GraphInspectorPresenter.ChangeType.SelectedNodes) != 0)
m_PresenterHash = presenterHash;
m_ContentContainer.Clear();
if (presenter.selectionCount > 1)
{
var element = new VisualElement { name = "selectionCount", text = string.Format("{0} nodes selected.", presenter.selectionCount) };
m_ContentContainer.Add(element);
}
else if (presenter.editor != null)
var selectionHash = UIUtilities.GetHashCode(presenter.selectedNodes.Count, presenter.selectedNodes != null ? presenter.selectedNodes.FirstOrDefault() : null);
if (selectionHash != m_SelectionHash)
var view = (AbstractNodeEditorView)Activator.CreateInstance(m_TypeMapper.MapType(presenter.editor.GetType()));
view.presenter = presenter.editor;
m_ContentContainer.Add(view);
m_SelectionHash = selectionHash;
m_ContentContainer.Clear();
if (presenter.selectedNodes.Count > 1)
{
var element = new VisualElement { name = "selectionCount", text = string.Format("{0} nodes selected.", presenter.selectedNodes.Count) };
m_ContentContainer.Add(element);
}
else if (presenter.selectedNodes.Count == 1)
{
var node = presenter.selectedNodes.First();
var view = (AbstractNodeEditorView)Activator.CreateInstance(m_TypeMapper.MapType(node.GetType()));
view.node = node;
m_ContentContainer.Add(view);
}
Dirty(ChangeType.Repaint);
}
public GraphInspectorPresenter presenter

{
if (m_Presenter == value)
return;
RemoveWatch();
if (m_Presenter != null)
m_Presenter.onChange -= OnChange;
OnDataChanged();
AddWatch();
OnChange(GraphInspectorPresenter.ChangeType.All);
m_Presenter.onChange += OnChange;
protected override Object[] toWatch
public void Dispose()
get { return new Object[] { m_Presenter }; }
if (m_Presenter != null)
m_Presenter.onChange -= OnChange;
}
}
}

107
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/IMGUISlotEditorView.cs


using System;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine.Graphing;
using Object = UnityEngine.Object;
public class IMGUISlotEditorView : DataWatchContainer
public class IMGUISlotEditorView : VisualElement
[SerializeField]
IMGUISlotEditorPresenter m_Presenter;
MaterialSlot m_Slot;
int m_SlotsHash;
ConcreteSlotValueType m_CurrentValueType = ConcreteSlotValueType.Error;
public override void OnDataChanged()
public IMGUISlotEditorView(MaterialSlot slot)
if (presenter == null)
{
Clear();
return;
}
if (presenter.slot.concreteValueType == m_CurrentValueType)
return;
Clear();
m_CurrentValueType = presenter.slot.concreteValueType;
Action onGUIHandler;
if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector4)
onGUIHandler = Vector4OnGUIHandler;
else if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector3)
onGUIHandler = Vector3OnGUIHandler;
else if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector2)
onGUIHandler = Vector2OnGUIHandler;
else if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector1)
onGUIHandler = Vector1OnGUIHandler;
else
return;
Add(new IMGUIContainer(onGUIHandler));
m_Slot = slot;
Add(new IMGUIContainer(OnGUIHandler));
void Vector4OnGUIHandler()
void OnGUIHandler()
if (presenter.slot == null)
if (m_Slot == null)
presenter.value = EditorGUILayout.Vector4Field(presenter.slot.displayName, presenter.value);
var newValue = SlotField(m_Slot);
if (newValue != m_Slot.currentValue)
{
m_Slot.currentValue = newValue;
m_Slot.owner.onModified(m_Slot.owner, ModificationScope.Node);
}
void Vector3OnGUIHandler()
static Vector4 SlotField(MaterialSlot slot)
if (presenter.slot == null)
return;
var previousWideMode = EditorGUIUtility.wideMode;
EditorGUIUtility.wideMode = true;
presenter.value = EditorGUILayout.Vector3Field(presenter.slot.displayName, presenter.value);
EditorGUIUtility.wideMode = previousWideMode;
}
void Vector2OnGUIHandler()
{
if (presenter.slot == null)
return;
var previousWideMode = EditorGUIUtility.wideMode;
EditorGUIUtility.wideMode = true;
presenter.value = EditorGUILayout.Vector2Field(presenter.slot.displayName, presenter.value);
EditorGUIUtility.wideMode = previousWideMode;
}
void Vector1OnGUIHandler()
{
if (presenter.slot == null)
return;
var previousWideMode = EditorGUIUtility.wideMode;
EditorGUIUtility.wideMode = true;
presenter.value = new Vector4(EditorGUILayout.FloatField(presenter.slot.displayName, presenter.value.x), 0, 0, 0);
EditorGUIUtility.wideMode = previousWideMode;
}
protected override Object[] toWatch
{
get { return new Object[] { presenter }; }
}
public IMGUISlotEditorPresenter presenter
{
get { return m_Presenter; }
set
{
if (value == m_Presenter)
return;
RemoveWatch();
m_Presenter = value;
OnDataChanged();
AddWatch();
}
if (slot.concreteValueType == ConcreteSlotValueType.Vector1)
return new Vector4(EditorGUILayout.FloatField(slot.displayName, slot.currentValue.x), 0, 0, 0);
if (slot.concreteValueType == ConcreteSlotValueType.Vector2)
return EditorGUILayout.Vector2Field(slot.displayName, slot.currentValue);
if (slot.concreteValueType == ConcreteSlotValueType.Vector3)
return EditorGUILayout.Vector3Field(slot.displayName, slot.currentValue);
if (slot.concreteValueType == ConcreteSlotValueType.Vector4)
return EditorGUILayout.Vector4Field(slot.displayName, slot.currentValue);
return Vector4.zero;
}
}
}

53
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/StandardNodeEditorView.cs


using System.Linq;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEditor.Graphing.Util;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector
{

VisualElement m_SlotsContainer;
VisualElement m_DefaultSlotValuesSection;
AbstractMaterialNode m_Node;
int m_SlotsHash;
new StandardNodeEditorPresenter presenter
public override INode node
{
get { return m_Node; }
set
{
if (value == m_Node)
return;
if (m_Node != null)
m_Node.onModified -= OnModified;
m_Node = value as AbstractMaterialNode;
OnModified(m_Node, ModificationScope.Node);
if (m_Node != null)
m_Node.onModified += OnModified;
}
}
public override void Dispose()
get { return (StandardNodeEditorPresenter) base.presenter; }
if (m_Node != null)
m_Node.onModified -= OnModified;
}
public StandardNodeEditorView()

Add(m_DefaultSlotValuesSection);
}
public override void OnDataChanged()
void OnModified(INode changedNode, ModificationScope scope)
if (presenter == null)
if (node == null)
m_HeaderView.title = presenter.node.name;
m_HeaderView.title = node.name;
var slotsHash = UIUtilities.GetHashCode(node.GetInputSlots<MaterialSlot>().Select(s => UIUtilities.GetHashCode(s.slotReference.nodeGuid.GetHashCode(), s.slotReference.slotId)));
m_SlotsContainer.Clear();
foreach (var slotEditorPresenter in presenter.slotEditorPresenters)
if (slotsHash != m_SlotsHash)
m_SlotsContainer.Add(new IMGUISlotEditorView { presenter = slotEditorPresenter });
}
m_SlotsHash = slotsHash;
m_SlotsContainer.Clear();
foreach (var slot in node.GetInputSlots<MaterialSlot>())
m_SlotsContainer.Add(new IMGUISlotEditorView(slot));
if (m_SlotsContainer.Any())
m_DefaultSlotValuesSection.RemoveFromClassList("hidden");
else
m_DefaultSlotValuesSection.AddToClassList("hidden");
if (m_SlotsContainer.Any())
m_DefaultSlotValuesSection.RemoveFromClassList("hidden");
else
m_DefaultSlotValuesSection.AddToClassList("hidden");
}
}
}
}

35
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/SurfaceMasterNodeEditorView.cs


public class SurfaceMasterNodeEditorView : AbstractNodeEditorView
{
NodeEditorHeaderView m_HeaderView;
AbstractSurfaceMasterNode m_Node;
new SurfaceMasterNodeEditorPresenter presenter
public override INode node
{
get { return m_Node; }
set
{
if (value == m_Node)
return;
if (m_Node != null)
m_Node.onModified -= OnModified;
m_Node = value as AbstractSurfaceMasterNode;
OnModified(m_Node, ModificationScope.Node);
if (m_Node != null)
m_Node.onModified += OnModified;
}
}
public override void Dispose()
get { return (SurfaceMasterNodeEditorPresenter)base.presenter; }
if (m_Node != null)
m_Node.onModified -= OnModified;
}
public SurfaceMasterNodeEditorView()

void OnGUIHandler()
{
if (presenter == null)
if (m_Node == null)
var options = presenter.materialNode.options;
var options = m_Node.options;
EditorGUI.BeginChangeCheck();
options.srcBlend = (SurfaceMaterialOptions.BlendMode)EditorGUILayout.EnumPopup("Src Blend", options.srcBlend);

options.renderQueue = (SurfaceMaterialOptions.RenderQueue)EditorGUILayout.EnumPopup("Render Queue", options.renderQueue);
options.renderType = (SurfaceMaterialOptions.RenderType)EditorGUILayout.EnumPopup("Render Type", options.renderType);
if (EditorGUI.EndChangeCheck())
presenter.node.onModified(presenter.node, ModificationScope.Graph);
m_Node.onModified(m_Node, ModificationScope.Graph);
public override void OnDataChanged()
void OnModified(INode changedNode, ModificationScope scope)
if (presenter == null)
if (m_Node == null)
m_HeaderView.title = presenter.node.name;
m_HeaderView.title = m_Node.name;
Dirty(ChangeType.Repaint);
}
}
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphEditorPresenter.cs


set { m_GraphInspectorPresenter = value; }
}
public void Initialize(IGraph graph, IMaterialGraphEditWindow container, string graphName)
public void Initialize(IGraph graph, IMaterialGraphEditWindow container, string assetName)
m_GraphInspectorPresenter.Initialize(graphName);
m_GraphInspectorPresenter.Initialize(assetName, graph);
m_GraphPresenter = CreateInstance<MaterialGraphPresenter>();
m_GraphPresenter.Initialize(graph, container);

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


using System;
using UnityEngine;
using Object = UnityEngine.Object;
public class GraphEditorView : DataWatchContainer
public class GraphEditorView : DataWatchContainer, IDisposable
{
GraphView m_GraphView;
GraphInspectorView m_GraphInspectorView;

protected override Object[] toWatch
{
get { return new Object[] { m_Presenter }; }
}
public void Dispose()
{
if (m_GraphInspectorView != null) m_GraphInspectorView.Dispose();
}
}
}

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/UIUtilities.cs


using System;
using System.Linq;
namespace UnityEditor.Graphing.Util
{

}
public static int GetHashCode(params object[] objects)
{
return GetHashCode(objects.AsEnumerable());
}
public static int GetHashCode<T>(IEnumerable<T> objects)
{
var hashCode = 17;
foreach (var @object in objects)

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/AbstractNodeEditorPresenter.cs.meta


fileFormatVersion: 2
guid: 97d910cfa5d2452e9ac7500b6cee25ab
timeCreated: 1503661223

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/IMGUISlotEditorPresenter.cs


using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector
{
public class IMGUISlotEditorPresenter : ScriptableObject
{
[SerializeField]
MaterialSlot m_Slot;
public MaterialSlot slot
{
get { return m_Slot; }
set { m_Slot = value; }
}
public Vector4 value
{
get { return m_Slot.currentValue; }
set
{
if (value == slot.currentValue)
return;
slot.currentValue = value;
m_Slot.owner.onModified(m_Slot.owner, ModificationScope.Node);
}
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/IMGUISlotEditorPresenter.cs.meta


fileFormatVersion: 2
guid: 7be91f540ac243ec9bf12002b0fb8c1d
timeCreated: 1504002750

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/StandardNodeEditorPresenter.cs.meta


fileFormatVersion: 2
guid: a0786fdde6014aa6b3222772757dbbb5
timeCreated: 1503661346

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/SurfaceMasterNodeEditorPresenter.cs.meta


fileFormatVersion: 2
guid: 99655571e90540559a9c31cfc126bb8d
timeCreated: 1504786938

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/AbstractNodeEditorPresenter.cs


using UnityEngine;
using UnityEngine.Graphing;
namespace UnityEditor.MaterialGraph.Drawing.Inspector
{
public abstract class AbstractNodeEditorPresenter : ScriptableObject
{
public abstract INode node { get; set; }
}
}

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/StandardNodeEditorPresenter.cs


using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector
{
public sealed class StandardNodeEditorPresenter : AbstractNodeEditorPresenter
{
[SerializeField]
AbstractMaterialNode m_Node;
[SerializeField]
List<IMGUISlotEditorPresenter> m_SlotEditorPresenters;
public override INode node
{
get { return m_Node; }
set
{
m_Node = (AbstractMaterialNode)value;
m_SlotEditorPresenters = new List<IMGUISlotEditorPresenter>();
foreach (var slot in node.GetInputSlots<MaterialSlot>())
{
if (slot.concreteValueType == ConcreteSlotValueType.Vector1
|| slot.concreteValueType == ConcreteSlotValueType.Vector2
|| slot.concreteValueType == ConcreteSlotValueType.Vector3
|| slot.concreteValueType == ConcreteSlotValueType.Vector4)
{
var slotEditorPresenter = CreateInstance<IMGUISlotEditorPresenter>();
slotEditorPresenter.slot = slot;
m_SlotEditorPresenters.Add(slotEditorPresenter);
}
}
}
}
public IEnumerable<IMGUISlotEditorPresenter> slotEditorPresenters
{
get { return m_SlotEditorPresenters; }
}
}
}

23
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/SurfaceMasterNodeEditorPresenter.cs


using UnityEngine;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector
{
public class SurfaceMasterNodeEditorPresenter : AbstractNodeEditorPresenter
{
[SerializeField]
AbstractSurfaceMasterNode m_Node;
public override INode node
{
get { return m_Node; }
set { m_Node = (AbstractSurfaceMasterNode)value; }
}
public AbstractSurfaceMasterNode materialNode
{
get { return m_Node; }
}
}
}
正在加载...
取消
保存