Exemplo n.º 1
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.Label("Parameters", EditorStyles.boldLabel);

            for (var index = 0; index < this.parameterInfos.Length; index++)
            {
                var parameterInfo = this.parameterInfos[index];

                var parameterValue = this.parameterValues[index];

                this.parameterValues[index] = InspectorUtils.DrawValueField(ObjectNames.NicifyVariableName(parameterInfo.Name),
                                                                            parameterInfo.ParameterType,
                                                                            parameterValue);
            }

            if (GUILayout.Button("Invoke"))
            {
                this.invokeAction(this.parameterValues);
            }
        }
Exemplo n.º 2
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)));
        }