Updates
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Contracts.Services.Gallery;
|
||||
using UnityEngine;
|
||||
@@ -7,7 +8,7 @@ namespace Darkmatter.Services.Gallery
|
||||
{
|
||||
public class GalleryService : IGalleryService
|
||||
{
|
||||
public async UniTask SaveImageAsync(Texture2D image, string fileName, string albumName = "Colorbook")
|
||||
public async UniTask SaveImageAsync(Texture2D image, string fileName, CancellationToken cancellationToken)
|
||||
{
|
||||
var permission = await NativeGallery.RequestPermissionAsync(NativeGallery.PermissionType.Write,
|
||||
NativeGallery.MediaType.Image);
|
||||
@@ -18,10 +19,12 @@ namespace Darkmatter.Services.Gallery
|
||||
}
|
||||
|
||||
var tcs = new UniTaskCompletionSource();
|
||||
var registration = cancellationToken.Register(() => tcs.TrySetCanceled(cancellationToken));
|
||||
|
||||
NativeGallery.SaveImageToGallery(image, albumName,
|
||||
NativeGallery.SaveImageToGallery(image, "Colorbook",
|
||||
filename: $"colorbook_{DateTime.UtcNow:yyyyMMdd_HHmmss}.png", callback: (success, path) =>
|
||||
{
|
||||
registration.Dispose();
|
||||
if (!success)
|
||||
{
|
||||
Debug.LogError("Failed to save image to gallery.");
|
||||
@@ -30,6 +33,7 @@ namespace Darkmatter.Services.Gallery
|
||||
{
|
||||
Debug.Log($"Image saved to gallery at: {path}");
|
||||
}
|
||||
|
||||
tcs.TrySetResult();
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:6e5063adab271564ba0098a06a8cebda"
|
||||
"GUID:6e5063adab271564ba0098a06a8cebda",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
Reference in New Issue
Block a user