Files
AppleHillsProduction/Assets/Scripts/Minigames/StatueDressup/Controllers/PhotoCaptureTestController.cs
Michal Pikulski 5bab6d9596 stash work
2025-11-27 11:29:45 +01:00

75 lines
2.5 KiB
C#

using UnityEngine;
using UnityEngine.UI;
using Utils;
namespace Minigames.StatueDressup.Controllers
{
/// <summary>
/// Minimal test for photo capture - just capture and save to disk
/// </summary>
public class PhotoCaptureTestController : MonoBehaviour
{
[Header("Required")]
[SerializeField] private RectTransform captureArea;
[SerializeField] private Button captureButton;
[Header("Optional - UI to hide during capture")]
[SerializeField] private GameObject[] hideTheseObjects;
private void Start()
{
if (captureButton != null)
{
captureButton.onClick.AddListener(OnCaptureClicked);
}
Debug.Log($"[PhotoCaptureTest] Ready. Photo save path: {PhotoManager.GetCaptureDirectory(CaptureType.StatueMinigame)}");
}
private void OnCaptureClicked()
{
if (captureArea == null)
{
Debug.LogError("[PhotoCaptureTest] Capture Area not assigned!");
return;
}
Debug.Log("[PhotoCaptureTest] Starting capture...");
StartCoroutine(CaptureCoroutine());
}
private System.Collections.IEnumerator CaptureCoroutine()
{
// Use new PhotoManager plug-and-play coroutine
yield return PhotoManager.CaptureAndSaveCoroutine(
CaptureType.StatueMinigame,
captureArea,
hideTheseObjects,
onSuccess: (photoId) =>
{
string path = $"{PhotoManager.GetCaptureDirectory(CaptureType.StatueMinigame)}/{photoId}.png";
Debug.Log($"[PhotoCaptureTest] ✅ SUCCESS! Photo saved: {path}");
// 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: {error}");
},
metadata: 0
);
}
private void OnDestroy()
{
if (captureButton != null)
captureButton.onClick.RemoveListener(OnCaptureClicked);
}
}
}