浏览代码

TypeMapper => GraphTypeMapper

Signed-off-by: joce <joce@unity3d.com>
/main
joce 8 年前
当前提交
2a1b5b99
共有 8 个文件被更改,包括 42 次插入42 次删除
  1. 6
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphInspector.cs
  2. 6
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphPresenter.cs
  3. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphPresenter.cs
  4. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphInspector.cs
  5. 26
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  6. 19
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/GraphTypeMapper.cs
  7. 19
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs
  8. 0
      /MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/GraphTypeMapper.cs.meta

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


{
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);
}

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


[Serializable]
public abstract class AbstractGraphPresenter : GraphViewPresenter
{
protected TypeMapper dataMapper { get; set; }
protected GraphTypeMapper typeMapper { get; set; }
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;

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphPresenter.cs


{
protected SerializedGraphPresenter()
{
dataMapper[typeof(SerializableNode)] = typeof(GraphNodePresenter);
typeMapper[typeof(SerializableNode)] = typeof(GraphNodePresenter);
}
}
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphInspector.cs


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)

26
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs


{
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);
}
}
}

19
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/GraphTypeMapper.cs


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);
}
}
}

19
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs


using System;
using RMGUI.GraphView;
using UnityEngine;
using UnityEngine.Graphing;
namespace UnityEditor.Graphing.Util
{
public class TypeMapper : BaseTypeMapper<INode, ScriptableObject>
{
public TypeMapper(Type fallbackType) : base(fallbackType)
{
}
protected override ScriptableObject InternalCreate(Type valueType)
{
return ScriptableObject.CreateInstance(valueType);
}
}
}

/MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs.meta → /MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/GraphTypeMapper.cs.meta

正在加载...
取消
保存