예제 #1
0
        /// <summary>
        /// Initialize drawer
        /// </summary>
        /// <param name="upperSectionMinSize">Upper section's minimum size</param>
        /// <param name="upperSectionGUIStyle">Upper section's GUI style</param>
        /// <param name="lowerSectionMinSize">Lower section's minimum size</param>
        /// <param name="lowerSectionGUIStyle">Lower section's GUI style</param>
        /// <param name="sliderPos">Slider's default position</param>
        public TwoSectionWithSliderDrawer(int upperSectionMinSize,
                                          int lowerSectionMinSize,
                                          int sliderPos)
        {
            upperSection = new SectionDrawer(upperSectionMinSize, SectionDrawer.PositionTab.Upper);
            lowerSection = new SectionDrawer(lowerSectionMinSize, SectionDrawer.PositionTab.Lower);
            sliderDrawer = new SliderDrawer();

            sliderDrawer.SliderPos = sliderPos;
        }
예제 #2
0
            private Rect GetRect(SliderDrawer sliderDrawer, Rect windowRect)
            {
                Vector2 minimumCorner = position == PositionTab.Upper
                                                               ? new Vector2(0, FixedBorderPos)
                                                               : new Vector2(0, sliderDrawer.SliderLowerBorderPos);

                Vector2 size = new Vector2(windowRect.width, CalculateHeight(sliderDrawer));

                return(new Rect(minimumCorner, size));
            }
예제 #3
0
            private int CalculateHeight(SliderDrawer sliderDrawer)
            {
                switch (position)
                {
                case PositionTab.Upper:
                    return(sliderDrawer.SliderUpperBorderPos - FixedBorderPos);

                case PositionTab.Lower:
                    return(FixedBorderPos - sliderDrawer.SliderLowerBorderPos);

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
예제 #4
0
            /// <summary>
            /// Draw the section
            /// </summary>
            /// <returns>The section's rect</returns>
            /// <param name="drawer"></param>
            /// <param name="sliderDrawer">Slider's drawer</param>
            public void Draw(GUIStyle style, Action drawer, SliderDrawer sliderDrawer, Rect windowRect)
            {
                Rect rect = GetRect(sliderDrawer, windowRect);

                GUILayout.BeginArea(rect);

                EditorGUILayout.BeginVertical(style);

                scrollPosition = GUILayout.BeginScrollView(scrollPosition);

                drawer();

                GUILayout.EndScrollView();

                EditorGUILayout.EndVertical();

                GUILayout.EndArea();
            }