Logo
UI Elements

Carousel

A sliding content carousel with animated transitions and indicators

Overview

Carousel displays a list of items that can be navigated manually or automatically. It supports animated slide transitions, indicators with progress timers, and click events on individual entries.

Items contain a title, description, background sprite, and custom click event. The component handles object creation, transition animation, indicator updates, and auto sliding based on a timer at runtime.


Properties

Content

NameTypeDescription
currentIndexintCurrently active item index
itemsList<Item>List of carousel entries

Each item contains:

FieldTypeDescription
titlestringDisplay name of the item
descriptionstringItem description text
backgroundSpriteBackground sprite used in the carousel preset
onClickUnityEventEvent triggered when the item is clicked

Settings

NameTypeDescription
useUnscaledTimeboolUses unscaled time for timers and animations
autoSlideboolEnables automatic sliding
autoSlideTimerfloatTime before moving to the next item
animationCurveAnimationCurveCurve used for slide transitions
animationDurationfloatDuration of slide animation
indicatorShrinkfloatScale applied to inactive indicators
slideOffsetVector2Offset direction for slide animation

References

NameTypeDescription
itemParentTransformParent where item objects are created
itemPresetGameObjectPrefab with CarouselPreset component
indicatorParentTransformParent where indicator objects are created
indicatorPresetGameObjectPrefab with CarouselIndicator component

Public Methods

NameParametersDescription
Initialize()NoneCreates objects, resets timer, and shows current item
NextItem()NoneSlides to the next item
PreviousItem()NoneSlides to the previous item
GoToItem(index)intSlides to a specific item
CurrentIndexpropertyReturns the current item index
IsTransitioningpropertyIndicates if a slide animation is in progress

Code Example

CarouselExample.cs
using UnityEngine;
using Evo.UI;

public class CarouselExample : MonoBehaviour
{
    public Carousel carousel;

    void Start()
    {
        // Change settings
        carousel.autoSlide = true;
        carousel.autoSlideTimer = 4f;

        // Go to next item manually
        carousel.NextItem();

        // Go to previous item
        carousel.PreviousItem();

        // Jump to index
        carousel.GoToItem(2);

        // Read current index
        Debug.Log("Current index: " + carousel.CurrentIndex);
    }
}

On this page