Add seeing mr Cement photos in the album
This commit is contained in:
3
Assets/Scripts/Minigames/Examples.meta
Normal file
3
Assets/Scripts/Minigames/Examples.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34a38264a29d495ba48983aff9916b13
|
||||
timeCreated: 1765803616
|
||||
251
Assets/Scripts/Minigames/Examples/PhotoSystemDebugger.cs
Normal file
251
Assets/Scripts/Minigames/Examples/PhotoSystemDebugger.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
namespace Minigames.Examples
|
||||
{
|
||||
/// <summary>
|
||||
/// Debug tool for diagnosing photo loading issues.
|
||||
/// Add to any GameObject in scene, then right-click in Inspector to run tests.
|
||||
/// </summary>
|
||||
public class PhotoSystemDebugger : MonoBehaviour
|
||||
{
|
||||
[ContextMenu("1. Check Photo Files on Disk")]
|
||||
private void CheckPhotoFiles()
|
||||
{
|
||||
Debug.Log("=== CHECKING PHOTO FILES ON DISK ===");
|
||||
|
||||
CheckPhotoFilesForType(CaptureType.StatueMinigame);
|
||||
CheckPhotoFilesForType(CaptureType.DivingMinigame);
|
||||
}
|
||||
|
||||
private void CheckPhotoFilesForType(CaptureType type)
|
||||
{
|
||||
string path = PhotoManager.GetCaptureDirectory(type);
|
||||
Debug.Log($"\n[{type}] Photo directory: {path}");
|
||||
Debug.Log($"[{type}] Directory exists: {System.IO.Directory.Exists(path)}");
|
||||
|
||||
if (System.IO.Directory.Exists(path))
|
||||
{
|
||||
var files = System.IO.Directory.GetFiles(path, "*.png");
|
||||
Debug.Log($"[{type}] PNG files found: {files.Length}");
|
||||
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
var fileInfo = new System.IO.FileInfo(file);
|
||||
Debug.Log($" ✓ {System.IO.Path.GetFileName(file)} ({fileInfo.Length / 1024}KB)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[{type}] No PNG files found in directory!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[{type}] Directory does not exist! No photos captured yet.");
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("2. Check Disk Photos")]
|
||||
private void CheckDiskPhotos()
|
||||
{
|
||||
Debug.Log("=== CHECKING DISK PHOTOS ===");
|
||||
|
||||
CheckPhotosForType(CaptureType.StatueMinigame);
|
||||
CheckPhotosForType(CaptureType.DivingMinigame);
|
||||
}
|
||||
|
||||
private void CheckPhotosForType(CaptureType type)
|
||||
{
|
||||
string directory = PhotoManager.GetCaptureDirectory(type);
|
||||
Debug.Log($"\n[{type}] Photo directory: {directory}");
|
||||
Debug.Log($"[{type}] Directory exists: {Directory.Exists(directory)}");
|
||||
|
||||
int count = PhotoManager.GetPhotoCount(type);
|
||||
Debug.Log($"[{type}] PhotoManager.GetPhotoCount(): {count}");
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
var photoIds = PhotoManager.GetPhotoIds(type, 10); // Show top 10
|
||||
Debug.Log($"[{type}] Latest {photoIds.Count} photos:");
|
||||
foreach (var id in photoIds)
|
||||
{
|
||||
string filePath = Path.Combine(directory, $"{id}.png");
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(filePath);
|
||||
Debug.Log($" ✓ {id} - {fileInfo.CreationTime:yyyy-MM-dd HH:mm:ss} ({fileInfo.Length / 1024}KB)");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($" ✗ {id} - FILE MISSING!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[{type}] No photos found on disk!");
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("3. Check AlbumPhotoSlot Components")]
|
||||
private void CheckAlbumPhotoSlots()
|
||||
{
|
||||
Debug.Log("=== CHECKING ALBUM PHOTO SLOTS ===");
|
||||
|
||||
var slots = FindObjectsByType<CardSystem.UI.Component.AlbumPhotoSlot>(FindObjectsSortMode.None);
|
||||
Debug.Log($"\nAlbumPhotoSlot components found in scene: {slots.Length}");
|
||||
|
||||
if (slots.Length == 0)
|
||||
{
|
||||
Debug.LogError("❌ NO ALBUMPHOTOSLOT COMPONENTS FOUND!");
|
||||
Debug.LogError("You need to add AlbumPhotoSlot components to GameObjects on your album pages.");
|
||||
return;
|
||||
}
|
||||
|
||||
var statueSlots = 0;
|
||||
var divingSlots = 0;
|
||||
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
bool isActive = slot.gameObject.activeInHierarchy;
|
||||
string status = isActive ? "✓ ACTIVE" : "✗ INACTIVE";
|
||||
|
||||
Debug.Log($" {status} - {slot.gameObject.name}");
|
||||
Debug.Log($" └─ CaptureType: {slot.CaptureType}");
|
||||
Debug.Log($" └─ Scene Path: {GetGameObjectPath(slot.gameObject)}");
|
||||
|
||||
if (slot.CaptureType == CaptureType.StatueMinigame) statueSlots++;
|
||||
else if (slot.CaptureType == CaptureType.DivingMinigame) divingSlots++;
|
||||
|
||||
if (!isActive)
|
||||
{
|
||||
Debug.LogWarning($" └─ WARNING: Slot is inactive! Make sure parent page is active when album opens.");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"\nSummary:");
|
||||
Debug.Log($" StatueMinigame slots: {statueSlots}");
|
||||
Debug.Log($" DivingMinigame slots: {divingSlots}");
|
||||
}
|
||||
|
||||
[ContextMenu("4. Check Album Page State")]
|
||||
private void CheckAlbumPageState()
|
||||
{
|
||||
Debug.Log("=== CHECKING ALBUM PAGE STATE ===");
|
||||
|
||||
var albumPage = FindFirstObjectByType<UI.CardSystem.AlbumViewPage>();
|
||||
|
||||
if (albumPage == null)
|
||||
{
|
||||
Debug.LogError("❌ AlbumViewPage not found in scene!");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"\n✓ AlbumViewPage found: {albumPage.gameObject.name}");
|
||||
Debug.Log($" └─ GameObject active: {albumPage.gameObject.activeInHierarchy}");
|
||||
Debug.Log($" └─ Component enabled: {albumPage.enabled}");
|
||||
|
||||
// Check if album is currently open
|
||||
if (UI.Core.UIPageController.Instance != null)
|
||||
{
|
||||
bool isCurrentPage = UI.Core.UIPageController.Instance.CurrentPage == albumPage;
|
||||
Debug.Log($" └─ Is current page: {isCurrentPage}");
|
||||
|
||||
if (!isCurrentPage)
|
||||
{
|
||||
Debug.LogWarning("Album is not currently open. Photo controller won't initialize until album opens.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("5. Test Photo Loading Directly")]
|
||||
private void TestPhotoLoadingDirectly()
|
||||
{
|
||||
Debug.Log("=== TESTING DIRECT PHOTO LOADING ===");
|
||||
|
||||
TestLoadForType(CaptureType.StatueMinigame);
|
||||
TestLoadForType(CaptureType.DivingMinigame);
|
||||
}
|
||||
|
||||
private void TestLoadForType(CaptureType type)
|
||||
{
|
||||
Debug.Log($"\n[{type}] Testing photo load...");
|
||||
|
||||
var photoIds = PhotoManager.GetPhotoIds(type, 1);
|
||||
|
||||
if (photoIds.Count == 0)
|
||||
{
|
||||
Debug.LogWarning($"[{type}] No photos to load!");
|
||||
return;
|
||||
}
|
||||
|
||||
string photoId = photoIds[0];
|
||||
Debug.Log($"[{type}] Attempting to load: {photoId}");
|
||||
|
||||
Texture2D photo = PhotoManager.LoadPhoto(type, photoId);
|
||||
|
||||
if (photo != null)
|
||||
{
|
||||
Debug.Log($"[{type}] ✓ Photo loaded successfully!");
|
||||
Debug.Log($" └─ Resolution: {photo.width}x{photo.height}");
|
||||
Debug.Log($" └─ Format: {photo.format}");
|
||||
|
||||
// Clean up
|
||||
Destroy(photo);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[{type}] ✗ Failed to load photo!");
|
||||
Debug.LogError($" └─ Photo file may be missing or corrupted");
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("6. Run Full Diagnostic")]
|
||||
private void RunFullDiagnostic()
|
||||
{
|
||||
Debug.Log("╔════════════════════════════════════════════╗");
|
||||
Debug.Log("║ PHOTO SYSTEM FULL DIAGNOSTIC ║");
|
||||
Debug.Log("╚════════════════════════════════════════════╝");
|
||||
|
||||
CheckPhotoFiles();
|
||||
Debug.Log("──────────────────────────────────────────────────");
|
||||
|
||||
CheckDiskPhotos();
|
||||
Debug.Log("\n" + new string('─', 50) + "\n");
|
||||
|
||||
CheckAlbumPhotoSlots();
|
||||
Debug.Log("\n" + new string('─', 50) + "\n");
|
||||
|
||||
CheckAlbumPageState();
|
||||
Debug.Log("\n" + new string('─', 50) + "\n");
|
||||
|
||||
TestPhotoLoadingDirectly();
|
||||
|
||||
Debug.Log("\n╔════════════════════════════════════════════╗");
|
||||
Debug.Log("║ DIAGNOSTIC COMPLETE ║");
|
||||
Debug.Log("╚════════════════════════════════════════════╝");
|
||||
}
|
||||
|
||||
// Helper method to get full GameObject path
|
||||
private string GetGameObjectPath(GameObject obj)
|
||||
{
|
||||
string path = obj.name;
|
||||
Transform parent = obj.transform.parent;
|
||||
|
||||
while (parent != null)
|
||||
{
|
||||
path = parent.name + "/" + path;
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cafdab23229342d5aabc0d6218984c5a
|
||||
timeCreated: 1765803616
|
||||
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Core;
|
||||
using Core.Lifecycle;
|
||||
using Minigames.StatueDressup.PhotoGallery;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Utils;
|
||||
|
||||
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using Utils;
|
||||
|
||||
namespace Minigames.StatueDressup.Controllers
|
||||
namespace Minigames.StatueDressup.PhotoGallery
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages enlarged photo preview display.
|
||||
@@ -12,32 +12,32 @@ namespace Minigames.StatueDressup.Controllers
|
||||
/// </summary>
|
||||
public class PhotoEnlargeController
|
||||
{
|
||||
private readonly GameObject backdrop;
|
||||
private readonly Transform enlargedContainer;
|
||||
private readonly float animationDuration;
|
||||
private readonly GameObject _backdrop;
|
||||
private readonly Transform _enlargedContainer;
|
||||
private readonly float _animationDuration;
|
||||
|
||||
private GameObject currentEnlargedPreview;
|
||||
private PhotoGridItem currentSourceItem;
|
||||
private GameObject _currentEnlargedPreview;
|
||||
private MonoBehaviour _currentSourceItem;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public PhotoEnlargeController(GameObject backdrop, Transform enlargedContainer, float animationDuration = 0.3f)
|
||||
{
|
||||
this.backdrop = backdrop;
|
||||
this.enlargedContainer = enlargedContainer;
|
||||
this.animationDuration = animationDuration;
|
||||
this._backdrop = backdrop;
|
||||
this._enlargedContainer = enlargedContainer;
|
||||
this._animationDuration = animationDuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a photo is currently enlarged
|
||||
/// </summary>
|
||||
public bool IsPhotoEnlarged => currentEnlargedPreview != null;
|
||||
public bool IsPhotoEnlarged => _currentEnlargedPreview != null;
|
||||
|
||||
/// <summary>
|
||||
/// Enlarge a photo from a grid item
|
||||
/// </summary>
|
||||
public void EnlargePhoto(PhotoGridItem sourceItem, GameObject previewPrefab, Texture2D photoTexture, float enlargedScale)
|
||||
public void EnlargePhoto(MonoBehaviour sourceItem, GameObject previewPrefab, Texture2D photoTexture, float enlargedScale)
|
||||
{
|
||||
if (sourceItem == null || previewPrefab == null || photoTexture == null)
|
||||
{
|
||||
@@ -46,30 +46,30 @@ namespace Minigames.StatueDressup.Controllers
|
||||
}
|
||||
|
||||
// Don't allow multiple enlargements
|
||||
if (currentEnlargedPreview != null)
|
||||
if (_currentEnlargedPreview != null)
|
||||
{
|
||||
Logging.Warning("[PhotoEnlargeController] Photo already enlarged");
|
||||
return;
|
||||
}
|
||||
|
||||
currentSourceItem = sourceItem;
|
||||
_currentSourceItem = sourceItem;
|
||||
|
||||
// Show backdrop
|
||||
if (backdrop != null)
|
||||
if (_backdrop != null)
|
||||
{
|
||||
backdrop.SetActive(true);
|
||||
_backdrop.SetActive(true);
|
||||
}
|
||||
|
||||
// Spawn preview clone
|
||||
currentEnlargedPreview = Object.Instantiate(previewPrefab, enlargedContainer);
|
||||
currentEnlargedPreview.transform.SetAsLastSibling();
|
||||
_currentEnlargedPreview = Object.Instantiate(previewPrefab, _enlargedContainer);
|
||||
_currentEnlargedPreview.transform.SetAsLastSibling();
|
||||
|
||||
// Position at source item's world position
|
||||
currentEnlargedPreview.transform.position = sourceItem.transform.position;
|
||||
currentEnlargedPreview.transform.localScale = sourceItem.transform.localScale;
|
||||
_currentEnlargedPreview.transform.position = sourceItem.transform.position;
|
||||
_currentEnlargedPreview.transform.localScale = sourceItem.transform.localScale;
|
||||
|
||||
// Set photo texture on preview
|
||||
var previewImage = currentEnlargedPreview.GetComponent<UnityEngine.UI.Image>();
|
||||
var previewImage = _currentEnlargedPreview.GetComponent<UnityEngine.UI.Image>();
|
||||
if (previewImage != null)
|
||||
{
|
||||
// Create sprite from texture
|
||||
@@ -82,10 +82,10 @@ namespace Minigames.StatueDressup.Controllers
|
||||
}
|
||||
|
||||
// Add click handler to preview
|
||||
var clickHandler = currentEnlargedPreview.GetComponent<EventTrigger>();
|
||||
var clickHandler = _currentEnlargedPreview.GetComponent<EventTrigger>();
|
||||
if (clickHandler == null)
|
||||
{
|
||||
clickHandler = currentEnlargedPreview.AddComponent<EventTrigger>();
|
||||
clickHandler = _currentEnlargedPreview.AddComponent<EventTrigger>();
|
||||
}
|
||||
|
||||
var pointerClickEntry = new EventTrigger.Entry { eventID = EventTriggerType.PointerClick };
|
||||
@@ -93,8 +93,8 @@ namespace Minigames.StatueDressup.Controllers
|
||||
clickHandler.triggers.Add(pointerClickEntry);
|
||||
|
||||
// Animate to center and scale up
|
||||
TweenAnimationUtility.AnimateLocalPosition(currentEnlargedPreview.transform, Vector3.zero, animationDuration);
|
||||
TweenAnimationUtility.AnimateScale(currentEnlargedPreview.transform, Vector3.one * enlargedScale, animationDuration);
|
||||
TweenAnimationUtility.AnimateLocalPosition(_currentEnlargedPreview.transform, Vector3.zero, _animationDuration);
|
||||
TweenAnimationUtility.AnimateScale(_currentEnlargedPreview.transform, Vector3.one * enlargedScale, _animationDuration);
|
||||
|
||||
// Play audio feedback
|
||||
AudioManager.Instance.LoadAndPlayUIAudio("card_albumdrop_deep", false);
|
||||
@@ -107,35 +107,35 @@ namespace Minigames.StatueDressup.Controllers
|
||||
/// </summary>
|
||||
public void ShrinkPhoto()
|
||||
{
|
||||
if (currentEnlargedPreview == null || currentSourceItem == null)
|
||||
if (_currentEnlargedPreview == null || _currentSourceItem == null)
|
||||
{
|
||||
Logging.Warning("[PhotoEnlargeController] No photo to shrink");
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide backdrop
|
||||
if (backdrop != null)
|
||||
if (_backdrop != null)
|
||||
{
|
||||
backdrop.SetActive(false);
|
||||
_backdrop.SetActive(false);
|
||||
}
|
||||
|
||||
// Get target position from source item
|
||||
Vector3 targetWorldPos = currentSourceItem.transform.position;
|
||||
Vector3 targetScale = currentSourceItem.transform.localScale;
|
||||
Vector3 targetWorldPos = _currentSourceItem.transform.position;
|
||||
Vector3 targetScale = _currentSourceItem.transform.localScale;
|
||||
|
||||
GameObject previewToDestroy = currentEnlargedPreview;
|
||||
GameObject previewToDestroy = _currentEnlargedPreview;
|
||||
|
||||
// Animate back to source position
|
||||
Pixelplacement.Tween.Position(previewToDestroy.transform, targetWorldPos, animationDuration, 0f, Pixelplacement.Tween.EaseInOut);
|
||||
TweenAnimationUtility.AnimateScale(previewToDestroy.transform, targetScale, animationDuration, () =>
|
||||
Pixelplacement.Tween.Position(previewToDestroy.transform, targetWorldPos, _animationDuration, 0f, Pixelplacement.Tween.EaseInOut);
|
||||
TweenAnimationUtility.AnimateScale(previewToDestroy.transform, targetScale, _animationDuration, () =>
|
||||
{
|
||||
// Destroy preview after animation
|
||||
Object.Destroy(previewToDestroy);
|
||||
});
|
||||
|
||||
// Clear references
|
||||
currentEnlargedPreview = null;
|
||||
currentSourceItem = null;
|
||||
_currentEnlargedPreview = null;
|
||||
_currentSourceItem = null;
|
||||
|
||||
Logging.Debug("[PhotoEnlargeController] Photo shrunk");
|
||||
}
|
||||
@@ -145,18 +145,18 @@ namespace Minigames.StatueDressup.Controllers
|
||||
/// </summary>
|
||||
public void Cleanup()
|
||||
{
|
||||
if (currentEnlargedPreview != null)
|
||||
if (_currentEnlargedPreview != null)
|
||||
{
|
||||
Object.Destroy(currentEnlargedPreview);
|
||||
currentEnlargedPreview = null;
|
||||
Object.Destroy(_currentEnlargedPreview);
|
||||
_currentEnlargedPreview = null;
|
||||
}
|
||||
|
||||
if (backdrop != null)
|
||||
if (_backdrop != null)
|
||||
{
|
||||
backdrop.SetActive(false);
|
||||
_backdrop.SetActive(false);
|
||||
}
|
||||
|
||||
currentSourceItem = null;
|
||||
_currentSourceItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user