How i add dynamic tab page ?

+1 vote
asked Mar 15, 2016 by erkan (180 points)
Hello. I want to add dynamic tab page in tab view. How i do that?
commented May 15, 2018 by tomtominc (110 points)
Did you ever figure this out? I'd like to dynamically add pages as well.

1 Answer

0 votes
answered Mar 15, 2016 by admin (31,720 points)
Hey there!

Sorry, it's currently not possible to do that dynamically :/
One thing I can think of, is maybe create all the tabs you need in advance, and at Awake/Start, you disable the TabItems you don't want to show for now (located under TabView/Tab Bar/Container/).
And when you want to add a new tab, instead of adding one, you just activate this TabItem, so it will look like a tab has been added.

Maybe this workaround can help you?

~Yohan
commented May 2, 2016 by Dennis
Forgive my ignorance, I haven't gone totally through all the code yet but in tabView you have your initialization script that does everything with the pages/items arrays.

Couldn't you push new items into those two arrays and re-initialize?
commented May 4, 2016 by Dennis Smolek

So.... No reply on here but thats the method I did. 

I created a simple reset function and added it on the tabView class:

        protected void resetTabs () {
            Component[] tabMarkers = gameObject.GetComponentsInChildren<TabItem>();
            foreach(Component comp in tabMarkers) {
                GameObject.Destroy(comp.gameObject);
            }
            m_TabItemTemplate.gameObject.SetActive(true);
        }

So all you have to do is add a tabPage element to the same container which is super easy. Then call that resetTabs function, then call Start() again which resets everything...

commented Aug 22, 2016 by admin (31,720 points)
Sorry I missed your message...
Glad you find a solution!

~ Yohan
commented May 15, 2018 by tomtominc (110 points)
Hey, is this the only function I need to add a tab page? What is TabItem?
Welcome to MaterialUI support! Ask us anything :)
...