joce
8 年前
当前提交
cfc167d9
共有 6 个文件被更改,包括 39 次插入 和 81 次删除
-
19MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphInspector.cs
-
15MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphPresenter.cs
-
7MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphPresenter.cs
-
37MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphInspector.cs
-
32MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System; |
|||
using RMGUI.GraphView; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
public class TypeMapper |
|||
public class TypeMapper : BaseDataMapper<INode, ScriptableObject> |
|||
private readonly Dictionary<Type, Type> m_Mappings = new Dictionary<Type, Type>(); |
|||
private readonly Type m_Default; |
|||
|
|||
public TypeMapper() : this(null) {} |
|||
|
|||
public TypeMapper(Type defaultType) |
|||
public TypeMapper(Type fallbackType) : base(fallbackType) |
|||
m_Default = defaultType; |
|||
public void Clear() |
|||
protected override ScriptableObject InternalCreate(Type valueType) |
|||
m_Mappings.Clear(); |
|||
} |
|||
|
|||
public void AddMapping(Type from, Type to) |
|||
{ |
|||
m_Mappings[from] = to; |
|||
} |
|||
|
|||
public Type MapType(Type type) |
|||
{ |
|||
Type found = null; |
|||
while (type != null) |
|||
{ |
|||
if (m_Mappings.TryGetValue(type, out found)) |
|||
break; |
|||
type = type.BaseType; |
|||
} |
|||
return found ?? m_Default; |
|||
return ScriptableObject.CreateInstance(valueType); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue