Logo
Layout

Pages

A gesture-based swipeable page system

Overview

Pages is a page navigation and swiping system that supports touch/mouse gestures, animated transitions, button navigation, and event callbacks. Each page contains a content object, optional button reference, and full animation control with elastic drag resistance.

The component handles showing the selected page, hiding or disabling others, playing transition animations, responding to swipe gestures with velocity detection, and reacting to multiple triggers (buttons, swipe, or external code).

Preview

Usage

Add Pages component to a parent object

Assign the Container RectTransform that holds all pages

Create page entries and assign:

  • Page ID for referencing by string
  • Page Object for content panels
  • Page Button (optional) to switch on click

Set your Default Page Index

Configure swipe and animation settings

Swipe to navigate or click assigned page buttons


Properties

References

FieldTypeDescription
containerRectTransformParent container that holds all pages

Pages

FieldTypeDescription
pagesList<Page>List of page definitions
defaultPageIndexintIndex of the page to open at Start
pageIDstringOptional unique ID for string based switching
pageObjectRectTransformContent object for the page
pageButtonButtonClicking this button opens the page

Settings

NameTypeDescription
disableInvisiblePagesboolCompletely disables pages that are not selected
useUnscaledTimeboolUse real time instead of game time scale
interruptTransitionsboolAllow drag gestures to interrupt ongoing transitions

Swipe Settings

NameTypeDescription
swipeThresholdfloatDistance threshold (0.1-0.9) to trigger page change
elasticResistancefloatResistance factor (0.1-1) when dragging beyond bounds
velocityThresholdfloatVelocity required for quick swipe detection
swipeDirectionSwipeDirectionHorizontal or Vertical swipe direction

Animation Settings

NameTypeDescription
transitionCurveAnimationCurveEasing curve for page transitions
transitionDurationfloatDuration of the transition (0-2 seconds)
pageSpacingfloatSpacing between pages

Events

NameTypeDescription
onPageChangedUnityEvent<int>Triggered when a new page becomes active

Public Methods

NameParametersDescription
OpenPage(int index, bool animate)int, boolSwitch to a page by index with optional animation
OpenNextPage()NoneNavigate to the next page
OpenPreviousPage()NoneNavigate to the previous page
PositionPages()NoneRepositions all pages based on current settings

Public Properties

NameTypeDescription
CurrentPageIndexintReturns the active page index
IsTransitioningboolReturns true if a transition animation is playing

Code Example

PagesExample.cs
using UnityEngine;
using Evo.UI;

public class PagesExample : MonoBehaviour
{
    public Pages pages;

    void Start()
    {
        // Configure page behavior
        pages.disableInvisiblePages = true;
        pages.swipeDirection = Pages.SwipeDirection.Horizontal;
        pages.swipeThreshold = 0.3f;
        pages.interruptTransitions = true;

        // Event: log the selected page index
        pages.onPageChanged.AddListener(index =>
        {
            Debug.Log("Current Page: " + index);
        });

        // Open default page
        pages.OpenPage(0);
    }

    public void GoToOnboarding()
    {
        pages.OpenPage(0);
    }

    public void GoToTutorial()
    {
        pages.OpenPage(1);
    }

    public void NextPage()
    {
        if (!pages.IsTransitioning)
        {
            pages.OpenNextPage();
        }
    }

    public void PreviousPage()
    {
        if (!pages.IsTransitioning)
        {
            pages.OpenPreviousPage();
        }
    }
}

On this page