Example #1
0
        ReorderableList GetList(SerializedProperty property)
        {
            var(initialize, list) = ReorderableDrawer.GetList(property);
            if (initialize)
            {
                list.drawElementCallback      += DrawCondition;
                list.onAddDropdownCallback    += AddCondition;
                list.getElementHeightCallback += GetConditionHeight;
                list.onRemoveCallback         += OnConditionRemoved;
            }

            return(list);
        }
        private void DrawField(ReflectionInfo info, SerializedProperty property)
        {
            if (!info.IsVisible)
            {
                return;
            }

            var result = info.CheckValidate(target, property);

            if (!result)
            {
                ValidatorWindow.GetInstance().RegisterValidation(result, target);
                GUILayout.BeginVertical(EditorStyles.helpBox);
            }

            if (!property.isArray || property.type == "string")
            {
                // Somehow check if this type can be drawn other way
                // Is it defined with attribute?
                EditorGUILayout.PropertyField(property, true);
            }
            else
            {
                Pair <bool, ReorderableList> list = ReorderableDrawer.GetList(property);

                if (property.arrayElementType.Equals(typeof(GenericParameter).Name) &&
                    list.First)
                {
                    list.Second.drawElementCallback      += GenericParameterDrawer;
                    list.Second.onAddDropdownCallback    += GenericParameterAdd;
                    list.Second.getElementHeightCallback += (e, i) => 16;
                }

                list.Second.DoLayoutList();
            }

            if (!result)
            {
                GUILayout.BeginVertical();
                using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
                {
                    GUILayout.Box(SpaceEditorStyles.GetValidationIcon(result.Status), GUIStyle.none, GUILayout.Width(24));
                    GUILayout.Label(result.Message, EditorStyles.wordWrappedMiniLabel);
                }
                GUILayout.EndVertical();
                GUILayout.EndVertical();
            }
        }
        private void DrawField(ReflectionInfo info, SerializedProperty property)
        {
            if (!info.IsVisible)
            {
                return;
            }

            var result = info.CheckValidate(target, property);

            if (!result)
            {
                ValidatorWindow.GetInstance().RegisterValidation(result, target);
                GUILayout.BeginVertical(EditorStyles.helpBox);
            }

            if (!property.isArray || property.type == "string")
            {
                // Somehow check if this type can be drawn other way
                // Is it defined with attribute?
                EditorGUILayout.PropertyField(property, true);
            }
            else
            {
                ReorderableList list = ReorderableDrawer.GetList(property);
                list.DoLayoutList();
            }

            if (!result)
            {
                GUILayout.BeginVertical();
                using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
                {
                    GUILayout.Box(SpaceEditorStyles.GetValidationIcon(result.Status), GUIStyle.none, GUILayout.Width(24));
                    GUILayout.Label(result.Message, EditorStyles.wordWrappedMiniLabel);
                }
                GUILayout.EndVertical();
                GUILayout.EndVertical();
            }
        }
        private void DrawField(ReflectionInfo info, SerializedProperty property)
        {
            if (!info.IsVisible)
            {
                return;
            }

            var result = info.CheckValidate(target, property);

            if (!result)
            {
                ValidatorWindow.GetInstance().RegisterValidation(result, target);

                var rect             = GUILayoutUtility.GetLastRect();
                var spacedPadding    = (info.Spaced ? 24 : 0);
                var notSpacedPadding = (info.Spaced ? 0 : 0);
                rect.y      += rect.height + spacedPadding + notSpacedPadding;
                rect.height  = EditorGUI.GetPropertyHeight(property) - spacedPadding;
                rect.y      += 1;
                rect.width  += rect.x + 4;
                rect.x       = 0;
                rect.height += 2;
                GUI.color    = new Color(0.6f, 0f, 0f, 0.6f);
                GUI.Box(rect, GUIContent.none, SpaceEditorStyles.LightBox);
                GUI.color = Color.white;
                GUILayout.BeginVertical();
            }

            if (!property.isArray || property.type == "string")
            {
                // Somehow check if this type can be drawn other way
                // Is it defined with attribute?
                EditorGUILayout.PropertyField(property, true);
            }
            else
            {
                var(initialize, list) = ReorderableDrawer.GetList(property);
                if (initialize)
                {
                    if (property.arrayElementType.Equals(typeof(Variant).Name))
                    {
                        list.drawElementCallback      += GenericParameterDrawer;
                        list.onAddDropdownCallback    += GenericParameterAdd;
                        list.getElementHeightCallback += (e, i) => 16;
                    }
                    else if (property.arrayElementType.Equals(typeof(Framework.Parameter).Name))
                    {
                        list.drawElementCallback      += ParameterDraw;
                        list.onAddDropdownCallback    += ParameterAdd;
                        list.getElementHeightCallback += (e, i) => 16;
                    }
                }

                list.DoLayoutList();
            }

            if (!result)
            {
                GUILayout.BeginVertical();
                using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
                {
                    GUILayout.Box(SpaceEditorStyles.GetValidationIcon(result.Status), GUIStyle.none, GUILayout.Width(24));
                    GUILayout.Label(result.Message, EditorStyles.wordWrappedMiniLabel);
                }
                GUILayout.EndVertical();
                GUILayout.EndVertical();
            }
        }