Ejemplo n.º 1
0
        private object DrawMemberData(string memberName, Type memberType, object memberValue, int level)
        {
            if (level < MaxLevel)
            {
                var context = memberValue as Context;
                if (context != null)
                {
                    bool foldout;
                    this.foldoutDictionary.TryGetValue(level + memberName, out foldout);
                    foldout = this.foldoutDictionary[level + memberName] = EditorGUILayout.Foldout(foldout, memberName);
                    if (foldout)
                    {
                        this.DrawObjectData(context, level + 1);
                    }

                    return(context);
                }

                var dictionary = memberValue as DataDictionary;
                if (dictionary != null)
                {
                    bool foldout;
                    this.foldoutDictionary.TryGetValue(level + memberName, out foldout);
                    foldout = this.foldoutDictionary[level + memberName] = EditorGUILayout.Foldout(foldout, memberName);
                    if (foldout)
                    {
                        this.DrawDictionaryData(dictionary, level + 1);
                    }

                    return(dictionary);
                }

                var enumerable = memberValue as IEnumerable;
                if (enumerable != null && memberType.IsGenericType)
                {
                    var itemType = ReflectionUtils.GetEnumerableItemType(memberType);

                    bool foldout;
                    this.foldoutDictionary.TryGetValue(level + memberName, out foldout);
                    foldout = this.foldoutDictionary[level + memberName] = EditorGUILayout.Foldout(foldout, memberName);
                    if (foldout)
                    {
                        this.DrawEnumerableData(enumerable, memberType, itemType, level + 1);
                    }

                    return(enumerable);
                }
            }

            // Draw data trigger.
            var dataTrigger = memberValue as DataTrigger;

            if (dataTrigger != null)
            {
                InspectorUtils.DrawDataTrigger(memberName, dataTrigger);
                return(dataTrigger);
            }

            return(InspectorUtils.DrawValueField(memberName, memberType, memberValue,
                                                 (name, type, value) => this.DrawCustomTypeData(name, type, value, level)));
        }