浏览代码
Extracted type mapping functionality into own class such that it can be re-used for node inspector
/main
Extracted type mapping functionality into own class such that it can be re-used for node inspector
/main
Peter Bay Bastian
8 年前
当前提交
8dd129c5
共有 5 个文件被更改,包括 74 次插入 和 36 次删除
-
26MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs
-
5MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphDataSource.cs
-
27MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/MaterialGraphDataSource.cs
-
40MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs
-
12MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/TypeMapper.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEditor.Graphing.Util |
|||
{ |
|||
public class TypeMapper |
|||
{ |
|||
private readonly Dictionary<Type, Type> m_Mappings = new Dictionary<Type, Type>(); |
|||
private readonly Type m_Default; |
|||
|
|||
public TypeMapper() : this(null) {} |
|||
|
|||
public TypeMapper(Type defaultType) |
|||
{ |
|||
m_Default = defaultType; |
|||
} |
|||
|
|||
public void Clear() |
|||
{ |
|||
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; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: efaba3c359b73408c9888998f9a4c87d |
|||
timeCreated: 1482407708 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue