Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch out lottie files at runtime #19

Open
gardyna opened this issue Oct 16, 2023 · 3 comments
Open

Switch out lottie files at runtime #19

gardyna opened this issue Oct 16, 2023 · 3 comments

Comments

@gardyna
Copy link

gardyna commented Oct 16, 2023

I have a situation where I have to choose between several lottie files at runtime to display. I don't think having several gameobjects in the scene and selecting between those is elegant. Would it be possible to add a "SetLottie" function to the AnimatedImage object?

@gindemit
Copy link
Owner

Hello @gardyna, thanks a lot for the suggestion! Sorry for the long reply, I was busy on other projects. I will implement the API for this feature in the next versions.

@JonFaull
Copy link

I have a situation where I have to choose between several lottie files at runtime to display. I don't think having several gameobjects in the scene and selecting between those is elegant. Would it be possible to add a "SetLottie" function to the AnimatedImage object?

This would be very useful.

@gindemit
Copy link
Owner

Hey @gardyna and @JonFaull I just reviewed again the existing implementation.
The AnimatedImage monobeh does has a public method LoadFromAnimationJson()
You can use it on the same AnimatedImage instance to load new animations. It will automatically unload the already loaded animation. No need to dispose it explicitly.
You need to provide at least 3 parameters:
string json, uint width, uint height

You can see an example how to use this method on the dev branch in the repo_root/unity/RLottieUnity/Assets/LottiePlugin/Tests/Runtime/src/AnimatedImageTests.cs file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants