コード例 #1
0
        public static ScrollableDropdownSelection CreateNew(Rect position, string[] selections, Setting <int> referenceSetting, int showItems)
        {
            var element = new ScrollableDropdownSelection();

            element.cursorLimits = new Rect(
                position.x - new AutoScaleFloat(10f),
                position.y - new AutoScaleFloat(10f),
                position.width + new AutoScaleFloat(20f),
                position.height * showItems + Style.VerticalMargin * (showItems + 1) + (showItems * Style.Height * 0.8f) + new AutoScaleFloat(20f)
                );

            element.refSet      = referenceSetting;
            element.boxPosition = new Rect(
                position.x,
                position.y,
                position.width,
                position.height * showItems + Style.VerticalMargin * (showItems - 1) + (showItems * Style.Height * 0.8f)
                );

            element.viewRect = new Rect(0f, 0f, position.width, position.height * selections.Length + (Style.VerticalMargin * 1.5f * (selections.Length + 1)));
            element.rect     = new SmartRect(0f, 0f, position.width, position.height);
            element.animator = new Animation.DropDownAnimation(element, position, showItems + 1);
            element.Enable();
            element.initialSelection = referenceSetting.Value;
            element.selections       = selections;
            return(element);
        }
コード例 #2
0
        public static ScrollableDropdownSelection CreateNew(GUIBase baseGUI, Rect position, string[] selections, Setting <int> referenceSetting, int showItems)
        {
            if (showItems > selections.Length)
            {
                throw new System.InvalidOperationException("showItems should be more then selections. You could use not scrollable DropdownSeleection in this case");
            }
            var element = new ScrollableDropdownSelection();

            element.guiOwner = baseGUI;

            element.cursorLimits = new Rect(
                position.x - new AutoScaleFloat(10f),
                position.y - new AutoScaleFloat(10f),
                position.width + new AutoScaleFloat(20f),
                position.height * showItems + Style.VerticalMargin * (showItems + 1) + (showItems * Style.Height * 0.8f) + new AutoScaleFloat(20f)
                );

            element.refSet      = referenceSetting;
            element.boxPosition = new Rect(
                position.x,
                position.y,
                position.width,
                position.height * showItems + Style.VerticalMargin * (showItems - 1) + (showItems * Style.Height * 0.8f)
                );

            element.viewRect = new Rect(0f, 0f, position.width, position.height * selections.Length + (Style.VerticalMargin * (selections.Length - 1)) + (4 * (selections.Length - 1)));
            element.rect     = new SmartRect(0f, 0f, position.width, position.height);
            element.animator = new Animation.DropDownAnimation(element, position, showItems + 1);
            element.Enable();
            element.initialSelection = referenceSetting.Value;
            element.selections       = selections;
            return(element);
        }