private static void Init()
        {
            if (inspectorFieldParsers != null && inspectorTypeParsers != null)
            {
                return;
            }

            inspectorFieldParsers = new Dictionary <string, FieldInspectorParser>();
            List <Type> parserTypes = AssemblyTool.FindTypesInCurrentDomainWhereExtend <FieldInspectorParser>();

            foreach (var parserType in parserTypes)
            {
                var obj = ReflecTool.Instantiate(parserType);
                Debug.Log(parserType.ToString() + "   " + (obj == null));
                FieldInspectorParser fieldInspectorParser = obj as FieldInspectorParser;
                Debug.Log(parserType.ToString() + "   " + (fieldInspectorParser == null));
                inspectorFieldParsers.Add(fieldInspectorParser.Name, fieldInspectorParser);
            }

            inspectorTypeParsers = new Dictionary <Type, DefaultTypeInspector>();
            parserTypes          = AssemblyTool.FindTypesInCurrentDomainWhereExtend <DefaultTypeInspector>();
            foreach (var parserType in parserTypes)
            {
                DefaultTypeInspector defaultTypeInspector = ReflecTool.Instantiate(parserType) as DefaultTypeInspector;
                inspectorTypeParsers.Add(defaultTypeInspector.GetInspectorType(), defaultTypeInspector);
            }
        }
        public static object GenericField(
            string name,
            object value,
            Type t,
            FieldInfo fieldInfo,
            object instance,
            bool withName = true)
        {
            if (t == null)
            {
                return(value);
            }

            Init();

            if (fieldInfo != null)
            {
                //检查是否有字段解析支持
                InspectorStyle       inspectorStyle = fieldInfo.GetAttribute <InspectorStyle>();
                FieldInspectorParser parser         = null;

                if (inspectorStyle != null)
                {
                    name = inspectorStyle.Name;
                    if (inspectorStyle.ParserName != null)
                    {
                        inspectorFieldParsers.TryGetValue(inspectorStyle.ParserName, out parser);
                    }
                }

                if (parser != null)
                {
                    return(parser.ParserFiled(inspectorStyle, value, t, fieldInfo, instance, withName));
                }
            }

            //检查是否有默认类型解析
            if (inspectorTypeParsers.ContainsKey(t))
            {
                return(inspectorTypeParsers[t].Show(name, value, t, fieldInfo, instance, withName));
            }

            //默认显示
            if (t == typeof(string))
            {
                if (withName)
                {
                    return(EditorGUILayout.TextField(name, (string)value));
                }
                return(EditorGUILayout.TextField((string)value));
            }

            if (t == typeof(bool))
            {
                if (withName)
                {
                    return(EditorGUILayout.Toggle(name, (bool)value));
                }
                return(EditorGUILayout.Toggle((bool)value));
            }

            if (t == typeof(int))
            {
                if (withName)
                {
                    return(EditorGUILayout.IntField(name, (int)value));
                }
                return(EditorGUILayout.IntField((int)value));
            }

            if (t == typeof(uint))
            {
                if (withName)
                {
                    return((uint)EditorGUILayout.IntField(name, Convert.ToInt32((uint)value)));
                }
                return((uint)EditorGUILayout.IntField(Convert.ToInt32((uint)value)));
            }

            if (t == typeof(float))
            {
                if (withName)
                {
                    return(EditorGUILayout.FloatField(name, (float)value));
                }
                return(EditorGUILayout.FloatField((float)value));
            }

            if (t == typeof(Vector2))
            {
                if (withName)
                {
                    return(EditorGUILayout.Vector2Field(name, (Vector2)value));
                }
                return(EditorGUILayout.Vector2Field("", (Vector2)value));
            }

            if (t == typeof(Vector3))
            {
                if (withName)
                {
                    return(EditorGUILayout.Vector3Field(name, (Vector3)value));
                }
                return(EditorGUILayout.Vector3Field("", (Vector3)value));
            }

            if (t == typeof(Vector4))
            {
                if (withName)
                {
                    return(EditorGUILayout.Vector4Field(name, (Vector4)value));
                }
                return(EditorGUILayout.Vector4Field("", (Vector4)value));
            }


            if (t == typeof(Quaternion))
            {
                var quat = (Quaternion)value;
                var vec4 = new Vector4(quat.x, quat.y, quat.z, quat.w);
                if (withName)
                {
                    vec4 = EditorGUILayout.Vector4Field(name, vec4);
                }
                else
                {
                    vec4 = EditorGUILayout.Vector4Field("", vec4);
                }

                return(new Quaternion(vec4.x, vec4.y, vec4.z, vec4.w));
            }

            if (t == typeof(Color))
            {
                if (withName)
                {
                    return(EditorGUILayout.ColorField(name, (Color)value));
                }
                return(EditorGUILayout.ColorField((Color)value));
            }

            if (t == typeof(Rect))
            {
                if (withName)
                {
                    return(EditorGUILayout.RectField(name, (Rect)value));
                }
                return(EditorGUILayout.RectField((Rect)value));
            }

            if (t == typeof(AnimationCurve))
            {
                if (withName)
                {
                    return(EditorGUILayout.CurveField(name, (AnimationCurve)value));
                }
                return(EditorGUILayout.CurveField((AnimationCurve)value));
            }

            if (t == typeof(Bounds))
            {
                if (withName)
                {
                    return(EditorGUILayout.BoundsField(name, (Bounds)value));
                }
                return(EditorGUILayout.BoundsField((Bounds)value));
            }

            if (typeof(IList).IsAssignableFrom(t))
            {
                return(ListEditor(name, (IList)value, t));
            }

            if (t.IsSubclassOf(typeof(System.Enum)))
            {
                bool hasAttribute = t.HasAttribute <FlagsAttribute>();
                if (hasAttribute)
                {
                    if (withName)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label(name, GUILayout.Width(150));
                        FlagsEnumEditor(value, fieldInfo, instance);
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        FlagsEnumEditor(value, fieldInfo, instance);
                    }
                    return(fieldInfo.GetValue(instance));
                }
                else
                {
                    if (withName)
                    {
                        return(EditorGUILayout.EnumPopup(name, (System.Enum)value));
                    }
                    return(EditorGUILayout.EnumPopup((System.Enum)value));
                }
            }
            if (typeof(UnityEngine.Object).IsAssignableFrom(t))
            {
                if (withName)
                {
                    return(EditorGUILayout.ObjectField(name, (UnityEngine.Object)value, t, true));
                }
                return(EditorGUILayout.ObjectField((UnityEngine.Object)value, t, true));
            }

            if (value == null)
            {
                try
                {
                    value = ReflecTool.Instantiate(fieldInfo.FieldType);
                    fieldInfo.SetValue(instance, value);
                }
                catch (Exception e)
                {
                    // ignored
                }
            }

            if (value != null)
            {
                GUILayout.BeginVertical();
                if (withName)
                {
                    GUILayout.Label(name);
                }
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUILayout.BeginVertical();
                ShowObject(value);
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }

            return(value);
        }