Changing Tabs?

+1 vote
asked Jan 27, 2016 by anonymous
Hi, I wonder how can I create a new button to change to a certain tab? What events should I use in OnClick?

1 Answer

0 votes
answered Jan 28, 2016 by admin (31,720 points)
 
Best answer

Hello!

You need to call the method: SetPage(int index) on TabView. (index being the index of the tab)
Currently it's only possible to do that via code, and not the inspector because we forgot to add a small method, but it will be available in 1.0.2!

If you want to fix it right now, open MaterialUI/Scripts/Components/Tabs/TabView.cs, around line 430, you'll find a method name:

public void SetPage(int index, bool animate = true)

Rename it to:

public void SetPage(int index, bool animate)

And just above it, add the following method:

public void SetPage(int index)
{
    SetPage(index, true);
}
commented Jan 28, 2016 by anonymous
Interesting. the bool should be "bool animate" though.

I wonder why the same method will only display in the inspector when it has one argument.
commented Jan 29, 2016 by admin (31,720 points)
Well, this is how Unity event system seems to work, only accepting methods with just one parameter ;)

PS: Yes thanks for the typo on animate, I've edited the answer.
Welcome to MaterialUI support! Ask us anything :)
...