Exemple #1
0
        /// <summary>
        /// Creates a tab.
        /// </summary>
        /// <param name="helper">The <see cref="UIHelper"/>.</param>
        /// <param name="tabstrip">The <see cref="UITabstrip"/> this tab should belong to.</param>
        /// <param name="buttonWidth">The width of the tab button.</param>
        /// <param name="title">The title of the tab.</param>
        /// <returns>A <see cref="UIHelper"/> object of the newly created tab.</returns>
        public static UIHelper AddTab(this UIHelper helper, UITabstrip tabstrip, float buttonWidth, string title)
        {
            var tabstripGo = GameObject.Find(GameObjectDefs.ID_KEYMAPPING_TABSTRIP);  //TODO(earalov): replace with custom code

            if (tabstripGo == null)
            {
                return(helper);
            }
            UITabstrip keyMappingTabstrip = tabstripGo.GetComponent <UITabstrip>();
            UIButton   buttonTemplate     = null;

            if (keyMappingTabstrip == null)
            {
                buttonTemplate = keyMappingTabstrip.GetComponentInChildren <UIButton>();
            }

            UIButton tabButton = tabstrip.AddTab(title, buttonTemplate, true);

            tabButton.playAudioEvents   = buttonTemplate.playAudioEvents;
            tabButton.pressedTextColor  = buttonTemplate.pressedTextColor;
            tabButton.focusedTextColor  = buttonTemplate.focusedTextColor;
            tabButton.disabledTextColor = buttonTemplate.disabledTextColor;
            tabButton.width             = buttonWidth;

            UIPanel tab = tabstrip.tabPages.components.Last() as UIPanel;

            tab.autoLayout          = true;
            tab.autoLayoutDirection = LayoutDirection.Vertical;
            tab.autoLayoutPadding   = new RectOffset(0, 0, 2, 0);
            return(new UIHelper(tab));
        }