3using System.Collections.Generic;
14 public static class pb_ComponentEditorResolver
19 readonly
static Dictionary<Type, Type> builtInComponentEditors =
new Dictionary<Type, Type>()
21 { typeof(Transform), typeof(pb_TransformEditor) },
22 { typeof(RectTransform), typeof(pb_TransformEditor) },
23 { typeof(MeshRenderer), typeof(pb_MeshRendererEditor) },
24 { typeof(Camera), typeof(pb_CameraEditor) },
26 { typeof(VideoPlayer), typeof(pb_VideoPlayerEditor) },
34 public static pb_ComponentEditor GetEditor(
Component component)
36 GameObject go =
new GameObject();
38 Type editorType =
null;
40 if( !builtInComponentEditors.TryGetValue(component.GetType(), out editorType) )
42 foreach(KeyValuePair<Type, Type> kvp
in builtInComponentEditors)
44 if(kvp.Key.IsAssignableFrom(component.GetType()))
46 editorType = kvp.Value;
52 go.name = component.name;
53 pb_ComponentEditor editor = (pb_ComponentEditor) go.AddComponent( editorType ?? typeof(pb_ComponentEditor) );
54 editor.SetComponent(component);
UnityEngine.Component Component