Exemplo n.º 1
0
        //
        public void DrawGUI()
        {
            GUI.skin = UI.skin;

            float dropdownWidth = 200f;
            float buttonWidth   = 30f;
            float commonHeight  = 30f;

            Rect    position  = new Rect(0f, 0f, dropdownWidth, commonHeight);
            Vector2 totalSize = new Vector2(dropdownWidth + 2f * (UI.spacing.x + buttonWidth), commonHeight);

            position.position = UI.Position(totalSize, anchor);

            // Dropdown
            int selected = UI.Dropdown(position, dropdownState);

            if (selected != dropdownState.selected)
            {
                OnValueChanged(selected);
            }

            bool cachedEnabled;

            // Previous
            cachedEnabled = GUI.enabled;
            GUI.enabled   = dropdownState.selected > 0;
            position      = new Rect(position.x + position.width + UI.spacing.x, position.y, buttonWidth, commonHeight);
            if (UI.Button(position, UI.labelArrowLeft))
            {
                OnPrevious();
            }
            GUI.enabled = cachedEnabled;

            // Next
            cachedEnabled = GUI.enabled;
            GUI.enabled   = dropdownState.selected < dropdownState.items.Count - 1;
            position      = new Rect(position.x + position.width + UI.spacing.x, position.y, buttonWidth, commonHeight);
            if (UI.Button(position, UI.labelArrowRight))
            {
                OnNext();
            }
            GUI.enabled = cachedEnabled;

            GUI.skin = null;
        }
Exemplo n.º 2
0
        //
        public void DrawGUI()
        {
            GUI.skin = UI.skin;

            Vector2 size     = new Vector2(200f, 30f);
            Rect    position = new Rect(Vector2.zero, size);

            position.position = UI.Position(size, anchor);

            // Dropdown
            int selected = UI.Dropdown(position, dropdownState);

            if (selected != dropdownState.selected)
            {
                OnValueChanged(selected);
            }

            GUI.skin = null;
        }