Logo
Layout

Tabs

A flexible tab system with animated transitions and title display

Overview

Tabs is a tab and panel switching system that supports animated transitions, tab titles, UI navigation, and event callbacks. Each tab contains a content object, button reference, optional default selections, and full animation control.

The component handles showing the selected tab, hiding or disabling others, playing transition animations, updating the title display, remembering the last selected UI element, and reacting to multiple triggers (buttons, IDs, or external code).

Preview

Usage

Add Tabs component to a parent object

Create tab entries and assign:

  • Tab ID for referencing by string
  • Tab Object for content panels
  • Tab Button to switch on click
  • First Selected (optional) for controller/keyboard UI navigation

Set your Default Tab Index

Optionally assign Title Object for the tab name display

Click to the assigned tab button or call OpenTab() from code to switch manually


Properties

Tabs

FieldTypeDescription
tabsList<Item>List of tab definitions
defaultTabIndexintIndex of the tab to open at Start
tabIDstringOptional unique ID for string based switching
tabObjectRectTransformContent object for the tab
tabButtonButtonClicking this button opens the tab
firstSelectedGameObjectFirst selected object for controller navigation
latestSelectedGameObjectAutomatically updated last selected object
canvasGroupCanvasGroupCached for animations
originalAnchoredPositionVector2Used for restoring position during slide animations

Animation

NameTypeDescription
animationTypeAnimationTypeNone, Fade, Scale, SlideHorizontal, SlideVertical
animationCurveAnimationCurveEasing curve for transitions
animationDurationfloatDuration of the transition
scaleOutMultiplierfloatScale used when hiding the old tab
scaleInMultiplierfloatScale used when showing the new tab
slideDistancefloatSlide offset applied during slide animations

Title Display

NameTypeDescription
titleObjectTextMeshProUGUIText object used to display current tab name
titleSlideCurveAnimationCurveCurve used when animating the title text
titleSlideDurationfloatTotal duration of title animation
titleChangeDelayfloatDelay before the title text updates
titleSlideOffsetVector2Offset direction for slide out/in movement

Settings

NameTypeDescription
useUnscaledTimeboolUse real time instead of game time scale
disableInvisibleTabsboolCompletely disables tabs that are not selected

Events

NameTypeDescription
onTabChangedUnityEvent<int>Triggered when a new tab becomes active

Public Methods

NameParametersDescription
OpenTab(int index)intSwitch to a tab by index
OpenTab(string id)stringSwitch to a tab using its ID
OpenFirstTab()NoneShortcut for index 0
OpenLastTab()NoneOpens the last tab
AddTab(item)ItemAdds a new tab at runtime
RemoveTab(index)intRemoves a tab by index
RemoveTab(id)stringRemoves a tab by ID
CurrentTabIndexpropertyReturns active tab index
CurrentTabIDpropertyReturns active tab ID
CurrentTabpropertyReturns active Item reference

Code Example

TabsExample.cs
using UnityEngine;
using Evo.UI;

public class TabsExample : MonoBehaviour
{
    public Tabs tabs;

    void Start()
    {
        // Default behavior
        tabs.OpenTab(0);

        // Event: print the selected tab index
        tabs.onTabChanged.AddListener(i =>
        {
            Debug.Log("Selected Tab Index: " + i);
        });

        // Configure tab transition
        tabs.disableInvisibleTabs = true;
    }

    public void OpenInventoryTab()
    {
        tabs.OpenTab("Inventory");
    }

    public void OpenSettingsTab()
    {
        tabs.OpenTab("Settings");
    }

    public void NextTab()
    {
        tabs.OpenNextTab();
    }
}

On this page