Table of Contents

Class ScrollableImage

Namespace
Fallencake.UI
Assembly
Fallencake.UI.dll

Represents a scrollable texture bound to a UnityEngine.UI.RawImage. Manages UV offset over time to create a seamless scrolling effect.

[Serializable]
public class ScrollableImage
Inheritance
object
ScrollableImage

Remarks

Call Init() once to cache the starting UnityEngine.UI.RawImage.uvRect and to initialize the current Offset. Then, on each frame, call UpdateOffset() (or let AnimatedImageScroller drive it) to advance the UV offset based on Speed. The offset wraps in the [0,1) range for both axes to avoid precision growth.

Properties

Image

The target UnityEngine.UI.RawImage whose UnityEngine.UI.RawImage.uvRect will be updated.

public RawImage Image { get; }

Property Value

RawImage

A reference to the UnityEngine.UI.RawImage component that displays the scrolling texture. Must not be null when Init() or UpdateOffset() are called.

Offset

Current UV offset applied to the Image's UnityEngine.UI.RawImage.uvRect.

public Vector2 Offset { get; }

Property Value

Vector2

The accumulated offset in UV space, wrapped to the [0,1) interval on each axis.

Speed

UV scrolling speed (units per second) applied to the texture.

public Vector2 Speed { get; }

Property Value

Vector2

A UnityEngine.Vector2 where X shifts the U coordinate and Y shifts the V coordinate. Positive X moves the texture to the left visually (increasing U), positive Y moves it down (increasing V), depending on the material/shader sampling. Defaults to UnityEngine.Vector2.right.

Methods

Init()

Initializes the scrollable image state by caching the starting UnityEngine.UI.RawImage.uvRect and setting Offset to its position.

public void Init()

Remarks

Invoke this after assigning Image. It is safe to call multiple times; the starting rectangle will be re-captured and the offset reset to that position.

UpdateOffset()

Advances Offset by Time.deltaTime * Speed, wraps it into [0,1), and applies it to the Image's UnityEngine.UI.RawImage.uvRect while preserving width and height.

public void UpdateOffset()

Remarks

Typically called once per frame. Use from Update() or your own update loop.

See Also