MVP implemented with: - placing, removing etc. decorations - saving the state, displaying it on the map, restoring when game restarts - saving screenshots to folder on device Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #65
75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Utils;
|
|
|
|
namespace Minigames.StatueDressup.Test
|
|
{
|
|
/// <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);
|
|
}
|
|
}
|
|
}
|