Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib
Git LFS file not shown
Git LFS file not shown
7 changes: 6 additions & 1 deletion com.unity.uiwidgets/Runtime/ui/painting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3099,7 +3099,12 @@ public override int GetHashCode()

public class Skottie : NativeWrapper {
public Skottie(string path) {
_setPtr(Skottie_Construct(path));
var Id = Skottie_Construct(path);
if(Id == IntPtr.Zero){
Debug.Log($"cannot load lottie from {path}, please check file exist and valid");
}else {
_setPtr(Id);
}
}

public override void DisposePtr(IntPtr ptr) {
Expand Down
22 changes: 20 additions & 2 deletions engine/src/lib/ui/painting/skottie.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fml::RefPtr<Skottie> Skottie::Create(char* path) {
path = (char*)fileOut;
#endif
sk_sp<skottie::Animation> animation_ = skottie::Animation::MakeFromFile(path);
if(animation_ == nullptr){
return nullptr;
}
return fml::MakeRefCounted<Skottie>(animation_);
}

Expand All @@ -32,19 +35,34 @@ float Skottie::duration() { return animation_->duration(); }
UIWIDGETS_API(Skottie*)
Skottie_Construct(char* path) {
fml::RefPtr<Skottie> skottie = Skottie::Create(path);
if(skottie.get() == nullptr){
return nullptr;
}
skottie->AddRef();
return skottie.get();
}

UIWIDGETS_API(void)
Skottie_Dispose(Skottie* ptr) { ptr->Release(); }
Skottie_Dispose(Skottie* ptr) {
if(ptr == nullptr){
return;
}
ptr->Release();
}

UIWIDGETS_API(void)
Skottie_Paint(Skottie* ptr, Canvas* canvas, float x, float y, float width,
float height, float frame) {
if(ptr == nullptr){
return;
}
ptr->paint(canvas, x, y, width, height, frame);
}

UIWIDGETS_API(float)
Skottie_Duration(Skottie* ptr) { return ptr->duration(); }
Skottie_Duration(Skottie* ptr) {
if(ptr == nullptr){
return 0;
}
return ptr->duration(); }
} // namespace uiwidgets