Cleanup code structure, code smells, rename paramter, break out more granular managers

This commit is contained in:
Michal Pikulski
2025-11-27 12:10:25 +01:00
parent d083c2873e
commit a57fca63bf
23 changed files with 1738 additions and 453 deletions

View File

@@ -0,0 +1,74 @@
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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: deab1758ddef4bdea0e2c50554eaf568
timeCreated: 1764077035