public void AddTab(string name, BaseVisualElementContainer content, bool setAsFirstSelectTab = false) { if (!tab.ContainsKey(name)) { tab.Add(name, content); } if (setAsFirstSelectTab) { currentTab = content; tabContent.Add(content.rootElement); } Button button = new Button(); button.name = name; button.text = name; tabNavigator.Add(button); button.clicked += () => { OnSwitchTab(button.name); }; }
private void OnSwitchTab(string tabName) { Debug.Log("On Switch To Tab" + tabName); tabContent.Remove(currentTab.rootElement); currentTab = tab[tabName]; tabContent.Add(currentTab.rootElement); //currentTab.rootElement.visible = true; }