Class ModularSpinner
- Namespace
- Fallencake.UI
- Assembly
- Fallencake.UI.dll
Configurable spinner control that delegates movement to a strategy handler and exposes a rich set of options for rotation geometry and behavior.
public class ModularSpinner : UIBehaviour, ISpinner
- Inheritance
-
objectObjectComponentBehaviourMonoBehaviourUIBehaviourModularSpinner
- Implements
Remarks
Uses a pluggable ISpinnerHandler implementation (e.g., Elliptical or Axial) selected by
SpinningType to animate elements inside rotationArea.
Provides utility methods to initialize from code and control play state via Spin()/Stop().
Properties
ElementsOffset
Spacing factor between elements along the path.
public float ElementsOffset { get; set; }
Property Value
- float
elementStartPosition
Starting positions of elements along the path.
public ElementStartPosition elementStartPosition { get; }
Property Value
elements
The transforms of individual spinning elements.
public List<RectTransform> elements { get; }
Property Value
- List<RectTransform>
facingDirection
Initial facing direction for elements.
public FacingDirection facingDirection { get; }
Property Value
isClockwise
Whether elements rotate clockwise.
public bool isClockwise { get; }
Property Value
- bool
isContinuousSpin
Whether to transition to synchronized continuous spin.
public bool isContinuousSpin { get; }
Property Value
- bool
isLookForward
Whether elements should face forward along the path.
public bool isLookForward { get; }
Property Value
- bool
isSimpleDelay
Whether a simple delay model is used.
public bool isSimpleDelay { get; }
Property Value
- bool
movementCurve
Movement easing curve for element rotation.
public AnimationCurve movementCurve { get; }
Property Value
- AnimationCurve
rotationArea
The area within which the animation is laid out.
public RectTransform rotationArea { get; }
Property Value
- RectTransform
rotationDelay
Delay between starting consecutive element rotations.
public float rotationDelay { get; }
Property Value
- float
rotationSpeed
Duration (in seconds) for a full rotation.
public float rotationSpeed { get; }
Property Value
- float
startAngle
Starting rotation angle in degrees.
public int startAngle { get; }
Property Value
- int
Methods
InitSpinners()
Stops current animation, re-initializes internals and updates the play flag.
public void InitSpinners()
Initialize(List<RectTransform>, RectTransform, int, float, float, float, bool, bool, bool, bool, bool, bool, SpinningType, FacingDirection, AnimationCurve)
Fully initializes the spinner with explicit elements, area, angles and behavior options.
public void Initialize(List<RectTransform> elements, RectTransform rotationArea, int startAngle, float rotationTime, float elementsOffset, float rotationDelay, bool isPlayOnEnable, bool isSpinning, bool isClockwise, bool isLookForward, bool isSimpleDelay, bool isContinuousSpin, SpinningType spinningType, FacingDirection facingDirection, AnimationCurve movementCurve)
Parameters
elementsList<RectTransform>Spinning elements.
rotationAreaRectTransformThe bounds used to layout spinning.
startAngleintStarting angle in degrees.
rotationTimefloatTime for one full rotation, in seconds.
elementsOffsetfloatDistance factor between elements on the path.
rotationDelayfloatDelay between element starts.
isPlayOnEnableboolWhether to start spinning when enabled.
isSpinningboolInitial spinning flag.
isClockwiseboolRotate clockwise if true.
isLookForwardboolFace forward along path if true.
isSimpleDelayboolUse simple delay model if true.
isContinuousSpinboolEnable synchronized continuous spin after first loop.
spinningTypeSpinningTypeRotation geometry strategy.
facingDirectionFacingDirectionInitial facing direction.
movementCurveAnimationCurveEasing curve for movement.
Initialize(int, float, float, float, bool, bool, bool, bool, bool, bool, SpinningType, FacingDirection, AnimationCurve)
Initializes core parameters without changing elements collection and area.
public void Initialize(int startAngle, float rotationTime, float elementsOffset, float rotationDelay, bool isPlayOnEnable = true, bool isSpinning = true, bool isClockwise = true, bool isLookForward = false, bool isSimpleDelay = false, bool isContinuousSpin = false, SpinningType spinningType = SpinningType.Elliptical, FacingDirection facingDirection = FacingDirection.Top, AnimationCurve movementCurve = null)
Parameters
startAngleintStarting angle in degrees.
rotationTimefloatTime for one full rotation, in seconds.
elementsOffsetfloatDistance factor between elements on the path.
rotationDelayfloatDelay between element starts.
isPlayOnEnableboolWhether to play on enable.
isSpinningboolInitial spinning flag.
isClockwiseboolRotate clockwise if true.
isLookForwardboolFace forward along the path if true.
isSimpleDelayboolUse simple delay model if true.
isContinuousSpinboolEnable continuous spin synchronization after first loop.
spinningTypeSpinningTypeGeometry strategy.
facingDirectionFacingDirectionInitial facing direction.
movementCurveAnimationCurveEasing curve; defaults to linear if null.
OnRectTransformDimensionsChange()
This callback is called when the dimensions of an associated RectTransform change. It is always called before Awake, OnEnable, or Start. The call is also made to all child RectTransforms, regardless of whether their dimensions change (which depends on how they are anchored).
protected override void OnRectTransformDimensionsChange()
Spin()
Starts or continues the spinning animation.
public void Spin()
Stop()
Stops the spinning animation.
public void Stop()