private void ShowFields(FieldInfo[] components, AnyField listObject)
 {
     listObject.expand = EditorGUILayout.Foldout(listObject.expand, listObject.obj + "= " + listObject.value + ":");
     GUILayout.BeginHorizontal();
     {
         GUILayout.Space(10);
         if (listObject.expand)
         {
             GUILayout.BeginVertical();
             {
                 foreach (var item in components)
                 {
                     AnyField listObject1 = listObject.objectPath.Find(x => x.obj.Equals(item));
                     if (listObject1 == null)
                     {
                         listObject.objectPath.Add(new AnyField(item, 0, item.GetValue(listObject.obj)?.ToString()));
                     }
                     SelectFieldsObject(listObject1);
                 }
             }
             GUILayout.EndVertical();
         }
     }
     GUILayout.EndHorizontal();
 }
    private void SelectFieldsObject(AnyField getObj)
    {
        if (getObj == null)
        {
            return;
        }

        const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance;
        // MemberInfo[] members = getObj.obj.GetType().GetFields(bindingFlags).Cast<MemberInfo>()
        //     .Concat(getObj.obj.GetType().GetProperties(bindingFlags)).ToArray();
        var fields = getObj.obj.GetType().GetFields(bindingFlags);
        var props  = getObj.obj.GetType().GetProperties(bindingFlags);

        if (fields.Length > 0)
        {
            ShowFields(fields, getObj);
        }
        // if (props.Length > 0)
        // {
        //     ShowProperity(props, getObj);
        // }
        else
        {
            GUILayout.Label(getObj.obj + "= " + getObj.value);
        }
        if (getObj.obj.GetType() == typeof(GameObject))
        {
            var components = (getObj.obj as GameObject).GetComponents <MonoBehaviour>();
            foreach (var item in components)
            {
                AnyField listObject1 = getObj.objectPath.Find(x => x.obj.Equals(item));
                if (listObject1 == null)
                {
                    getObj.objectPath.Add(new AnyField(item, 0, item.ToString()));
                }
                SelectFieldsObject(listObject1);
            }
        }
        if (getObj.obj.GetType() is IEnumerable)
        {
            Debug.Log(getObj.obj.GetType());

            IEnumerable enumerable = (IEnumerable)getObj.obj;
            foreach (var item2 in enumerable)
            {
                AnyField listObject1 = getObj.objectPath.Find(x => x.obj.Equals(item2));
                if (listObject1 == null)
                {
                    getObj.objectPath.Add(new AnyField(item2, 0, item2.ToString()));
                }
                SelectFieldsObject(listObject1);
            }
        }
    }
 private void ShowEnum(MemberInfo[] components, AnyField listObject, AnyField getObj)
 {
     GUILayout.BeginHorizontal();
     {
         listObject.index = EditorGUILayout.Popup(listObject.index, components.Select(i => i.Name).ToArray());
         //listObject.objectPath.Add(new ListObject(components[listObject.index], listObject.index, GetValue(components[listObject.index], getObj.obj)));
         listObject.obj     = components[listObject.index];
         listObject.value   = GetValue(components[listObject.index], getObj.obj);
         listObject.nameObj = components[listObject.index].Name;
         ShowValue(listObject);
     }
     GUILayout.EndHorizontal();
 }
    private void SelectField(AnyField getObj, AnyField setObj)
    {
        //if (setObj.Equals(objectPath.LastOrDefault()))
        //Debug.Log(getObj.obj);
        FieldInfo[] fields = getObj.obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
        // PropertyInfo[] properties = GetProperties(getObj.obj) as PropertyInfo[];
        const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance;

        MemberInfo[] members = getObj.obj.GetType().GetFields(bindingFlags).Cast <MemberInfo>()
                               .Concat(getObj.obj.GetType().GetProperties(bindingFlags)).ToArray();
        if (members.Length > 0)
        {
            ShowEnum(members, setObj, getObj);
        }
    }
 private void ShowValue(AnyField obj)
 {
     if (obj.value is IEnumerable)
     {
         string line = "";
         var    list = obj.value as IEnumerable;
         if (list is string)
         {
             line = list.ToString();
         }
         else
         {
             foreach (var item in list)
             {
                 line += item + Environment.NewLine;
             }
         }
         GUILayout.Label(line);
     }
     else
     {
         GUILayout.Label(obj?.value?.ToString() ?? "null");
     }
 }
 private void ShowEnumComponent(object[] components, AnyField listObject)
 {
     listObject.index = EditorGUILayout.Popup(listObject.index, components.Select(i => i.GetType().ToString()).ToArray());
     listObject.obj   = components[listObject.index];
 }
    private void SelectComponent(GameObject obj, AnyField listObject)
    {
        var components = obj.GetComponents <MonoBehaviour>();

        ShowEnumComponent(components, listObject);
    }