CSL_Traffic.UI.RoadCustomizerPanel.CreateButton C# (CSharp) Method

CreateButton() protected method

protected CreateButton ( string name, string tooltip, string baseIconName, int index, UITextureAtlas atlas, UIComponent tooltipBox, bool enabled, bool grouped ) : UIButton
name string
tooltip string
baseIconName string
index int
atlas UITextureAtlas
tooltipBox UIComponent
enabled bool
grouped bool
return UIButton
        protected UIButton CreateButton(string name, string tooltip, string baseIconName, int index, UITextureAtlas atlas, UIComponent tooltipBox, bool enabled, bool grouped)
        {
            UIButton btn;
            if (this.m_scrollablePanel.childCount > this.m_objectIndex)
            {
                btn = (this.m_scrollablePanel.components[this.m_objectIndex] as UIButton);
            }
            else
            {
                GameObject asGameObject = UITemplateManager.GetAsGameObject(RoadCustomizerPanel.kItemTemplate);
                btn = (this.m_scrollablePanel.AttachUIComponent(asGameObject) as UIButton);
                btn.eventClick += OnClick;
            }
            btn.gameObject.GetComponent<TutorialUITag>().tutorialTag = name;
            btn.text = string.Empty;
            btn.name = name;
            btn.tooltipAnchor = UITooltipAnchor.Anchored;
            btn.tabStrip = true;
            btn.horizontalAlignment = UIHorizontalAlignment.Center;
            btn.verticalAlignment = UIVerticalAlignment.Middle;
            btn.pivot = UIPivotPoint.TopCenter;
            if (atlas != null)
            {
                btn.atlas = atlas;
                switch (m_panelType)
                {
                    case Panel.VehicleRestrictions:
                        SetVehicleButtonsThumbnails(btn);
                        break;
                    case Panel.SpeedRestrictions:
                        UIUtils.SetThumbnails("SpeedSignBackground", sm_thumbnailCoords["SpeedSignBackground"], atlas, sm_speedThumbnailStates);
                        SetSpeedButtonsThumbnails(btn);
                        break;
                    default:
                        break;
                }

            }
            if (index != -1)
            {
                btn.zOrder = index;
            }
            btn.verticalAlignment = UIVerticalAlignment.Bottom;
            btn.foregroundSpriteMode = UIForegroundSpriteMode.Fill;

            UIComponent uIComponent = (btn.childCount <= 0) ? null : btn.components[0];
            if (uIComponent != null)
            {
                uIComponent.isVisible = false;
            }
            btn.isEnabled = enabled;
            btn.state = UIButton.ButtonState.Disabled;
            btn.tooltip = tooltip;
            btn.tooltipBox = tooltipBox;
            btn.group = grouped ? this.m_scrollablePanel : null;
            this.m_objectIndex++;
            return btn;
        }