Skip to content

Carousel

There are two ways to build a carousel, depending on how many slides you have:

  • Static (scene-built) — for a small, fixed set (onboarding, a few featured cards): a horizontal AutoLayoutScrollView with snap turned on, and your slides added as plain children. No prefab, no code, no binding.
  • Virtualized (CarouselView) — for larger or data-driven sets: the CarouselView component pools and recycles slides from a prefab, and adds Slide / Loop / Fade modes, multi-item pages, and effects.

Drop an AutoLayoutScrollView (Row content) on a container, enable Snap to items, and add your slide cards as children. It snaps to each slide as you swipe — no CarouselView, no binding required.

Static (scene-built)

Static (scene-built)

A horizontal AutoLayoutScrollView with Snap to items on, and slides added as plain children — no prefab or binding. Best for a small, fixed set.

Add an AutoLayoutScrollView with Content Mode = Row, enable Snap to items, then parent your slide cards under it.

The CarouselView component is the data-driven path: register a prefab + item count and it pools slides, with Slide / Loop / Fade modes and multi-item pages.

Slide mode

The default Slide type scrolls within bounds and clamps at the first and last item. Set Type = CarouselType.Slide for a classic snap-to-item carousel.

Slide mode

Slide mode

The default Slide type clamps at boundaries — a classic snap-to-item carousel.

On the CarouselView component, under Type, set the carousel type to Slide.

Loop mode (wrap around)

Type = CarouselType.Loop enables infinite wrap-around scrolling — GoToNext() past the last item snaps back to the first.

Loop mode (wrap around)

Loop mode (wrap around)

Loop type enables infinite wrap-around scrolling; navigation past the last item snaps back to the first.

On the CarouselView component, under Type, set the type to Loop.

Fade mode (cross-fade)

Type = CarouselType.Fade stacks the items at the centre and cross-fades them by opacity — one visible at a time, 1 at the focused item fading to 0 at the neighbours — instead of sliding them. (For custom motion you can also add an ICarouselEffect, which receives each item’s normalized distance from centre.)

Fade mode (cross-fade)

Fade mode (cross-fade)

Type = Fade stacks items at the centre and cross-fades by opacity — one item visible at a time — instead of translating them.

On the CarouselView component, under Type, set the type to Fade.

Multi-item (PerPage > 1)

Set PerPage greater than 1 to show several slides in the viewport at once; item size is auto-calculated from viewport, padding, and gap.

Multi-item (PerPage > 1)

Multi-item (PerPage > 1)

Set PerPage greater than 1 to show several slides at once; item size is auto-calculated from the viewport.

On the CarouselView component, under Carousel Layout, set Per Page to 3.

Inspector Setup

  1. Create a container with AutoLayout and AutoLayoutScrollView.
  2. Add the CarouselView component.
  3. Register a prefab in the Prefabs list and set ItemCount + a bind callback via code (the component pools slides from the prefab — it does not lay out arbitrary scene children; for that, use the static scene-built carousel above).
  4. Toggle Virtualized off for immediate (non-pooled) instantiation while keeping the same prefab + bind.
FieldTypeDefaultDescription
DirectionCarouselDirectionHorizontalScroll axis
TypeCarouselTypeSlideSlide, Loop, or Fade
Per Pageint1Visible slides at once
FocusFocusModeCenterSnap alignment (Start, Center, End)
Paddingfloat0Edge padding in pixels
Gapfloat0Gap between items
Speedfloat400Transition/snap duration in ms (or set DurationSeconds in seconds)
Is RewindboolfalseWrap from last to first
Uniform Item Sizefloat0Fixed item size (0 = auto)
VirtualizedbooltrueEnable object pooling (only effective when prefabs are registered)
Overscan Countint2Extra items rendered offscreen
Default Pool Capacityint10Initial pool size per prefab type
PrefabsList-Prefab registrations (typeId + prefab + capacity)

Code Usage

Build it in the Inspector (see Inspector Setup above), or from code with the Code API.

Methods

MethodDescription
GoToItem(int index, bool animated = true)Navigate to specific item
GoToNext(bool animated = true)Navigate forward
GoToPrevious(bool animated = true)Navigate backward
AddEffect(ICarouselEffect effect)Add visual scroll effect
RemoveEffect(ICarouselEffect effect)Remove visual effect
RefreshItems()Refresh after data change (virtualized only)
RefreshItemsImmediate()Synchronous refresh (virtualized only)

Properties

PropertyTypeDescription
FocusedIndexintCurrently focused item index
IsSnappingboolSnap animation in progress
IsDraggingboolUser is dragging
ItemCountintTotal number of items
ScrollProgressfloatContinuous scroll progress

Events (CarouselView component)

Subscribe via Capture after building:

EventSignatureDescription
OnFocusChangedAction<int>Fires when focused item changes
OnFocusChangingAction<int, int>Fires during transition (from, to)
OnScrollProgressAction<float>Continuous scroll progress updates

Callbacks (virtualized mode)

CallbackSignatureDescription
GetItemCallbackFunc<int, object>Return data for index
GetItemTypeCallbackFunc<int, int>Return prefab type for index
BindItemCallbackAction<GameObject, int, object>Bind data to item
UnbindItemCallbackAction<GameObject, int>Cleanup on recycle

Builder API

MethodDescription
.Type(CarouselType)Slide, Loop, or Fade
.Focus(FocusMode)Start, Center, End
.PerPage(int)Visible slides at once
.Gap(float)Gap between items
.Padding(float)Edge padding
.Duration(float)Transition/snap duration in seconds (preferred)
.Speed(float)Same, in milliseconds (legacy)
.Rewind(bool)Wrap from last to first
.Easing(CarouselEasingFunction)Custom easing
.PoolCapacity(int)Default pool size per prefab
.Prefab(GameObject, int)Register type-0 prefab
.Prefab(int, GameObject, int)Register typed prefab
.Effect(ICarouselEffect)Add visual effect
.Delegate(ICarouselViewDelegate)Set delegate (overrides callbacks)
.ItemCount(int)Set total items
.GetItem(Func<int, object>)Set data callback
.BindItem(Action<GameObject, int, object>)Set bind callback
.UnbindItem(Action<GameObject, int>)Set unbind callback
.Capture(Action<CarouselView>)Capture reference (e.g. .Capture(view => m_Carousel = view))

Interfaces

  • ICarouselItem — Implement on prefab root for auto-binding.
  • ICarouselViewDelegate — Full data source control (overrides callbacks).
  • ICarouselEffect — Custom visual effects applied during scroll.

Notes

  • .Carousel(direction, configure) configures the parent in place and returns the parent LayoutBuilder — keep chaining or call .Build() to materialise the tree.
  • Use Focus = Center for typical snap-to-center carousels; Start snaps the leading edge; End snaps the trailing edge.
  • .Type(CarouselType.Loop) enables wrap-around scrolling; Slide clamps at boundaries; Fade stacks and cross-fades items by opacity.
Docs for AutoLayout PRO v1.0.0 Changelog