Signed-off-by: joce <joce@unity3d.com>
{
public abstract class AbstractGraphInspector : Editor
protected TypeMapper dataMapper { get; set; }
protected GraphTypeMapper typeMapper { get; set; }
protected List<INode> m_SelectedNodes = new List<INode>();
protected AbstractGraphInspector()
dataMapper = new TypeMapper(typeof(BasicNodeInspector));
typeMapper = new GraphTypeMapper(typeof(BasicNodeInspector));
}
public override void OnInspectorGUI()
m_Inspectors.Clear();
foreach (var node in m_SelectedNodes.OfType<SerializableNode>())
var inspector = (AbstractNodeInspector)dataMapper.Create(node);
var inspector = (AbstractNodeInspector)typeMapper.Create(node);
inspector.Initialize(node);
m_Inspectors.Add(inspector);
[Serializable]
public abstract class AbstractGraphPresenter : GraphViewPresenter
public IGraphAsset graphAsset { get; private set; }
protected AbstractGraphPresenter()
dataMapper = new TypeMapper(typeof(GraphNodePresenter));
typeMapper = new GraphTypeMapper(typeof(GraphNodePresenter));
void OnNodeChanged(INode inNode, ModificationScope scope)
if (m_Elements.OfType<GraphNodePresenter>().Any(e => e.node == node))
continue;
var nodeData = (GraphNodePresenter)dataMapper.Create(node);
var nodeData = (GraphNodePresenter)typeMapper.Create(node);
node.onModified += OnNodeChanged;
protected SerializedGraphPresenter()
dataMapper[typeof(SerializableNode)] = typeof(GraphNodePresenter);
typeMapper[typeof(SerializableNode)] = typeof(GraphNodePresenter);
protected AbstractMaterialGraphInspector()
dataMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterNodeInspector);
dataMapper[typeof(SubGraphInputNode)] = typeof(SubgraphInputNodeInspector);
dataMapper[typeof(SubGraphOutputNode)] = typeof(SubgraphOutputNodeInspector);
typeMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterNodeInspector);
typeMapper[typeof(SubGraphInputNode)] = typeof(SubgraphInputNodeInspector);
typeMapper[typeof(SubGraphOutputNode)] = typeof(SubgraphOutputNodeInspector);
private void OnPreviewNodeModified(INode node, ModificationScope scope)
protected MaterialGraphPresenter()
dataMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodePresenter);
dataMapper[typeof(ColorNode)] = typeof(ColorNodePresenter);
dataMapper[typeof(TextureNode)] = typeof(TextureNodePresenter);
dataMapper[typeof(UVNode)] = typeof(UVNodePresenter);
dataMapper[typeof(Vector1Node)] = typeof(Vector1NodePresenter);
dataMapper[typeof(Vector2Node)] = typeof(Vector2NodePresenter);
dataMapper[typeof(Vector3Node)] = typeof(Vector3NodePresenter);
dataMapper[typeof(Vector4Node)] = typeof(Vector4NodePresenter);
dataMapper[typeof(SubGraphNode)] = typeof(SubgraphNodePresenter);
dataMapper[typeof(RemapMasterNode)] = typeof(RemapMasterNodePresenter);
dataMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodePresenter);
dataMapper[typeof(AbstractSubGraphIONode)] = typeof(SubgraphIONodePresenter);
dataMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterPresenter);
typeMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodePresenter);
typeMapper[typeof(ColorNode)] = typeof(ColorNodePresenter);
typeMapper[typeof(TextureNode)] = typeof(TextureNodePresenter);
typeMapper[typeof(UVNode)] = typeof(UVNodePresenter);
typeMapper[typeof(Vector1Node)] = typeof(Vector1NodePresenter);
typeMapper[typeof(Vector2Node)] = typeof(Vector2NodePresenter);
typeMapper[typeof(Vector3Node)] = typeof(Vector3NodePresenter);
typeMapper[typeof(Vector4Node)] = typeof(Vector4NodePresenter);
typeMapper[typeof(SubGraphNode)] = typeof(SubgraphNodePresenter);
typeMapper[typeof(RemapMasterNode)] = typeof(RemapMasterNodePresenter);
typeMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodePresenter);
typeMapper[typeof(AbstractSubGraphIONode)] = typeof(SubgraphIONodePresenter);
typeMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterPresenter);
using System;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.Graphing;
namespace UnityEditor.Graphing.Util
public class GraphTypeMapper : BaseTypeMapper<INode, ScriptableObject>
public GraphTypeMapper(Type fallbackType) : base(fallbackType)
protected override ScriptableObject InternalCreate(Type valueType)
return ScriptableObject.CreateInstance(valueType);
public class TypeMapper : BaseTypeMapper<INode, ScriptableObject>
public TypeMapper(Type fallbackType) : base(fallbackType)