com.unity.uiwidgets icon indicating copy to clipboard operation
com.unity.uiwidgets copied to clipboard

Rive Animations with UiWidgets

Open pajama opened this issue 4 years ago • 3 comments

It seems Rive are officially working on a Unity Runtime, which is very exciting! https://feedback.rive.app/94 It seems like they're building it on top of Skia directly, which is also what flutter uses under the hood.

I'm under the impressions that UIWidgets 2 uses the full flutter engine under the hood. Since Rive already has a flutter runtime, would it be possible to load rive files with UIWidgets?

Thanks so much!

pajama avatar Oct 19 '21 17:10 pajama

Here is the Rive Flutter Runtime. I'm guessing a path forward would be to convert all of the lib dart files to c# using UIWidgets APIs. Have any other pub.dev packages been ported over to UIWidgets successfully? If I were to take on this effort, do you foresee any black boxes or brick walls that I'd run into with UIWidgets?

https://github.com/rive-app/rive-flutter

pajama avatar Oct 19 '21 18:10 pajama

Hi thanks for the sharing !

Very excited on this Rive-with-UIWidgets idea !

yes, UIWidgets 2.0 is using the full flutter engine and we have wrapped lots of its C++ APIs to C# already. If Rive is based on flutter APIs, I think loading and rendering rive files in UIWidgets is applicable.

We have already ported some light-weight packages (e.g., colorpicker) to UIWidgets and the work is very straight-forward. However, As a complex project, Rive may call some flutter engine APIs that we haven't wrapped yet. To address this issue, you have to modify the UIWidgets engine as you needed and recompiled it for your use case.

I am currently not very familiar with Rive so I can only give you very few advice now. Please feel free to ask in this thread and we will try our best to help you.

zhuxingwei avatar Oct 20 '21 08:10 zhuxingwei

Hi All! This is a super cool project. The Rive Flutter runtime is entirely in Dart and uses the Skia rendering abstraction exposed via Canvas in Flutter. If all of Canvas is exposed, Rive should work fine! Would love to see if we can facilitate using Rive with this framework!

Not entirely relevant, but if you're curious: The Rive Unity (work in progress) runtime has gone through a few experimental iterations. First off, it's written in C++ using our shared runtime code that runs on all non-Flutter runtimes (Web, iOS, Android, Tizen all use this C++ base layer). We've implemented two different rendering abstractions with Unity:

  1. Native Renderer, draws after all Unity content. Good for UI use cases only, no custom shaders, draw order with Unity content, etc.
  2. Native Rendering to texture (currently uses software rendering). This one is more flexible but users need to be much more performance conscious as it's very easy to create content that consumes a lot of CPU cycles for the software rendering. We want to spend time exploring render to texture with native hardware accelerations but there are other limitations we quickly run up against here too.

Both of these solutions have some simple C# behaviors you can attach to GameObjects as usual in Unity to help load .riv files and play animations and control inputs on state machines. We do the some simple marshaling between C# and C++.

Some more examples/details here: https://twitter.com/rive_app/status/1428474826813960199 https://twitter.com/luigirosso/status/1431030230739607555 https://twitter.com/luigirosso/status/1413250763539685381

luigi-rosso avatar Oct 21 '21 01:10 luigi-rosso