SkiaForUnity
Loading...
Searching...
No Matches
SkiaSharp.Unity.SkottiePlayerV2 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

bool customResolution
bool resetAfterFinished = false
bool autoPlay = false
bool loop = false
UnityAction< string > OnAnimationFinished
UnityAction OnAnimationInit

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 31 of file SkottiePlayerV2.cs.

Member Function Documentation

◆ GetDurations()

double SkiaSharp.Unity.SkottiePlayerV2.GetDurations ( )

Gets the total duration of the loaded animation in seconds.

Returns
The total duration of the loaded animation in seconds.

Definition at line 181 of file SkottiePlayerV2.cs.

◆ GetFps()

double SkiaSharp.Unity.SkottiePlayerV2.GetFps ( )

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

Returns
The FPS of the loaded animation.

Definition at line 173 of file SkottiePlayerV2.cs.

◆ GetStateName()

string SkiaSharp.Unity.SkottiePlayerV2.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 162 of file SkottiePlayerV2.cs.

◆ LoadAnimation()

void SkiaSharp.Unity.SkottiePlayerV2.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 119 of file SkottiePlayerV2.cs.

◆ PlayAnimation()

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

Initiates playback of the loaded animation.

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

Definition at line 189 of file SkottiePlayerV2.cs.

◆ SetState()

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

Sets the current state of the Lottie animation.

Parameters
nameThe name of the state to set.

Definition at line 139 of file SkottiePlayerV2.cs.

Member Data Documentation

◆ autoPlay

bool SkiaSharp.Unity.SkottiePlayerV2.autoPlay = false

Definition at line 43 of file SkottiePlayerV2.cs.

◆ customResolution

bool SkiaSharp.Unity.SkottiePlayerV2.customResolution

Definition at line 35 of file SkottiePlayerV2.cs.

◆ loop

bool SkiaSharp.Unity.SkottiePlayerV2.loop = false

Definition at line 45 of file SkottiePlayerV2.cs.

◆ OnAnimationFinished

UnityAction<string> SkiaSharp.Unity.SkottiePlayerV2.OnAnimationFinished

Definition at line 47 of file SkottiePlayerV2.cs.

◆ OnAnimationInit

UnityAction SkiaSharp.Unity.SkottiePlayerV2.OnAnimationInit

Definition at line 48 of file SkottiePlayerV2.cs.

◆ resetAfterFinished

bool SkiaSharp.Unity.SkottiePlayerV2.resetAfterFinished = false

Definition at line 41 of file SkottiePlayerV2.cs.