stash work
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Core;
|
||||
using Minigames.StatueDressup.Utils;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Utils;
|
||||
|
||||
namespace Minigames.StatueDressup.Controllers
|
||||
{
|
||||
@@ -24,7 +23,7 @@ namespace Minigames.StatueDressup.Controllers
|
||||
captureButton.onClick.AddListener(OnCaptureClicked);
|
||||
}
|
||||
|
||||
Debug.Log($"[PhotoCaptureTest] Ready. Photo save path: {StatuePhotoManager.GetPhotoDirectory()}");
|
||||
Debug.Log($"[PhotoCaptureTest] Ready. Photo save path: {PhotoManager.GetCaptureDirectory(CaptureType.StatueMinigame)}");
|
||||
}
|
||||
|
||||
private void OnCaptureClicked()
|
||||
@@ -41,47 +40,29 @@ namespace Minigames.StatueDressup.Controllers
|
||||
|
||||
private System.Collections.IEnumerator CaptureCoroutine()
|
||||
{
|
||||
// Hide UI
|
||||
foreach (var obj in hideTheseObjects)
|
||||
if (obj != null) obj.SetActive(false);
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
// Capture
|
||||
bool done = false;
|
||||
Texture2D photo = null;
|
||||
|
||||
StatuePhotoManager.CaptureAreaPhoto(captureArea, (texture) => {
|
||||
photo = texture;
|
||||
done = true;
|
||||
});
|
||||
|
||||
yield return new WaitUntil(() => done);
|
||||
|
||||
// Restore UI
|
||||
foreach (var obj in hideTheseObjects)
|
||||
if (obj != null) obj.SetActive(true);
|
||||
|
||||
// Save
|
||||
if (photo != null)
|
||||
{
|
||||
string photoId = StatuePhotoManager.SavePhoto(photo, 0);
|
||||
|
||||
if (!string.IsNullOrEmpty(photoId))
|
||||
// Use new PhotoManager plug-and-play coroutine
|
||||
yield return PhotoManager.CaptureAndSaveCoroutine(
|
||||
CaptureType.StatueMinigame,
|
||||
captureArea,
|
||||
hideTheseObjects,
|
||||
onSuccess: (photoId) =>
|
||||
{
|
||||
string path = $"{StatuePhotoManager.GetPhotoDirectory()}/{photoId}.png";
|
||||
string path = $"{PhotoManager.GetCaptureDirectory(CaptureType.StatueMinigame)}/{photoId}.png";
|
||||
Debug.Log($"[PhotoCaptureTest] ✅ SUCCESS! Photo saved: {path}");
|
||||
Debug.Log($"[PhotoCaptureTest] Photo size: {photo.width}x{photo.height}");
|
||||
}
|
||||
else
|
||||
|
||||
// Load back to verify
|
||||
Texture2D loadedPhoto = PhotoManager.LoadPhoto(CaptureType.StatueMinigame, photoId);
|
||||
if (loadedPhoto != null)
|
||||
{
|
||||
Debug.Log($"[PhotoCaptureTest] Photo size: {loadedPhoto.width}x{loadedPhoto.height}");
|
||||
}
|
||||
},
|
||||
onFailure: (error) =>
|
||||
{
|
||||
Debug.LogError("[PhotoCaptureTest] ❌ Failed to save photo");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[PhotoCaptureTest] ❌ Failed to capture photo");
|
||||
}
|
||||
Debug.LogError($"[PhotoCaptureTest] ❌ Failed: {error}");
|
||||
},
|
||||
metadata: 0
|
||||
);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
||||
Reference in New Issue
Block a user