gindemit / unity-rlottie

Unity library that plays Lottie Animation to Texture2D
MIT License
165 stars 26 forks source link

WebGL support #5

Open H-Maverick opened 1 year ago

H-Maverick commented 1 year ago

Will it be any support for WebGL ?

gindemit commented 1 year ago

Hello, thanks for the question! I haven't tried to build the plugin for web gl. I am affraid that it is not possible since the rlottie cpp library uses a lot of multi threading. But I'll write done into my todo list to try it out.

H-Maverick commented 1 year ago

Thanks a lot, i hope it is supported

enigmablue commented 1 year ago

would love this too.

enigmablue commented 1 year ago

This error on WebGL

WebGLBuild.framework.js:3 DllNotFoundException: Unable to load DLL 'LottiePlugin'. Tried the load the following dynamic libraries:

But i think we already know that

gilzoide commented 8 months ago

WebGLBuild.framework.js:3 DllNotFoundException: Unable to load DLL 'LottiePlugin'. Tried the load the following dynamic libraries:

WebGL native plugins are static libraries and should be using the special __Internal DLL name, just as it's done for iOS.

gilzoide commented 8 months ago

I am affraid that it is not possible since the rlottie cpp library uses a lot of multi threading.

It seems you must build rlottie with LOTTIE_THREAD_SUPPORT defined for multithreading to be used. I don't know how the WebGL static library was built, but if threading support is disabled in it, it's quite possible that it will just work.

zaixiaoqu commented 4 months ago

Hello everyone, I've searched all over the search engines and haven't found a good solution. Have you solved it?

gindemit commented 4 months ago

Hello @zaixiaoqu, I spend few days on it long time ago without any success. I would love to add the web gl support to the plugin.

zaixiaoqu commented 4 months ago

WebGLBuild.framework.js:3 DllNotFoundException: Unable to load DLL 'LottiePlugin'. Tried the load the following dynamic libraries:

WebGL native plugins are static libraries and should be using the special __Internal DLL name, just as it's done for iOS.

I am affraid that it is not possible since the rlottie cpp library uses a lot of multi threading.

It seems you must build rlottie with LOTTIE_THREAD_SUPPORT defined for multithreading to be used. I don't know how the WebGL static library was built, but if threading support is disabled in it, it's quite possible that it will just work.

Hello @gindemit, Thank you so much. I used @gilzoide 's open source code (https://github.com/gilzoide/unity-lottie-player), It successfully runs in the webgl environment. I think @gilzoide should have solved the problem according to the two methods he provided himself above.

gindemit commented 4 months ago

Oh, thanks @zaixiaoqu for pointing this out. I will take a shot again to solve this problem.

gilzoide commented 4 months ago

Yeah, I had to disable rlottie's threading support (that is, build it without LOTTIE_THREAD_SUPPORT defined) for it to not crash the game on WebGL. On CMake, setting LOTTIE_THREAD option to OFF on web builds should do the trick. That plus using [DllImport("__Internal")] should work =]