Пример #1
0
        protected override void DrawArrayInternal(Rect rect, int array_size)
        {
            EditProperty_Array property = GetProperty();

            EditorGUI.DrawRect(border_rect, Color.black);
            EditorGUI.DrawRect(background_rect, Color.gray);

            float x = background_rect.xMin;
            float y = background_rect.yMax;

            float element_width      = background_rect.width / array_size;
            float element_max_height = background_rect.height;

            for (int i = 0; i < array_size; i++)
            {
                float value;

                if (property.TryGetElementValue <float>(i, out value))
                {
                    float height = element_max_height * value.ConvertFromRangeToPercent(min_value, max_value);

                    EditorGUI.DrawRect(RectExtensions.CreateMinMaxRect(
                                           new Vector2(x, y),
                                           new Vector2(x + element_width, y - height)
                                           ), Color.cyan);
                }

                x += element_width;
            }

            Vector2 percent;

            if (GUIExtensions.MousePercentArea(background_rect, out percent, true, true))
            {
                int   index     = (int)(array_size * percent.x);
                float magnitude = 1.0f - percent.y;

                if (property.IsIndexValid(index))
                {
                    property.SetElementValue(index, magnitude.ConvertFromPercentToRange(min_value, max_value));
                }
            }
        }