SkiaForUnity
Loading...
Searching...
No Matches
SkiaSharp.Unity.SkottiePlayer Class Reference

Provides functionality to play and control Lottie animations in Unity. More...

Public Member Functions

void LoadAnimation (string json)
 Loads an animation from a JSON string and prepares it for playback.
void SetState (string name)
 Sets the current state of the Lottie animation.
string GetStateName ()
 Gets the name of the current animation state.
double GetFps ()
 Gets the frames per second (FPS) of the loaded animation.
double GetDurations ()
 Gets the total duration of the loaded animation in seconds.
void PlayAnimation (bool? reset=null)
 Initiates playback of the loaded animation.

Public Attributes

UnityAction< string > OnAnimationFinished

Detailed Description

Provides functionality to play and control Lottie animations in Unity.

// Example usage within the Start method:
[SerializeField]
SkottiePlayer skottiePlayer;
void Start() {
// Set the desired animation state
skottiePlayer.SetState("YourStateName");
// Start playing the animation
skottiePlayer.PlayAnimation();
}
Provides functionality to play and control Lottie animations in Unity.
void PlayAnimation(bool? reset=null)
Initiates playback of the loaded animation.
void SetState(string name)
Sets the current state of the Lottie animation.

Definition at line 30 of file SkottiePlayer.cs.

Member Function Documentation

◆ GetDurations()

double SkiaSharp.Unity.SkottiePlayer.GetDurations ( )

Gets the total duration of the loaded animation in seconds.

Returns
The total duration of the loaded animation in seconds.

Definition at line 168 of file SkottiePlayer.cs.

◆ GetFps()

double SkiaSharp.Unity.SkottiePlayer.GetFps ( )

Gets the frames per second (FPS) of the loaded animation.

Returns
The FPS of the loaded animation.

Definition at line 160 of file SkottiePlayer.cs.

◆ GetStateName()

string SkiaSharp.Unity.SkottiePlayer.GetStateName ( )

Gets the name of the current animation state.

Returns
The name of the current state if available; otherwise, an empty string.

Definition at line 149 of file SkottiePlayer.cs.

◆ LoadAnimation()

void SkiaSharp.Unity.SkottiePlayer.LoadAnimation ( string json)

Loads an animation from a JSON string and prepares it for playback.

Parameters
jsonThe JSON string containing the animation data.

Definition at line 114 of file SkottiePlayer.cs.

◆ PlayAnimation()

void SkiaSharp.Unity.SkottiePlayer.PlayAnimation ( bool? reset = null)

Initiates playback of the loaded animation.

Parameters
resetWhether to reset the animation to the beginning when finished.

Definition at line 176 of file SkottiePlayer.cs.

◆ SetState()

void SkiaSharp.Unity.SkottiePlayer.SetState ( string name)

Sets the current state of the Lottie animation.

Parameters
nameThe name of the state to set.

Definition at line 126 of file SkottiePlayer.cs.

Member Data Documentation

◆ OnAnimationFinished

UnityAction<string> SkiaSharp.Unity.SkottiePlayer.OnAnimationFinished

Definition at line 44 of file SkottiePlayer.cs.