Screenshots in Diving Minigame

This commit is contained in:
Michal Pikulski
2025-12-18 10:52:12 +01:00
parent 4e992ccf53
commit ca56e748ba
22 changed files with 1516 additions and 143 deletions

View File

@@ -42,6 +42,12 @@ namespace Minigames.DivingForPictures.PictureCamera
private Viewfinder viewfinderComponent;
private UnityEngine.Camera mainCamera;
private AudioSource _audioSource;
/// <summary>
/// The currently active Viewfinder component.
/// Exposed for screenshot system to access capture area and flyaway animation.
/// </summary>
public Viewfinder CurrentViewfinder => viewfinderComponent;
// Animation state
private float animationProgress = 0f;

View File

@@ -3,17 +3,30 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Input;
using UnityEngine.Serialization;
using Utils.UI;
namespace Minigames.DivingForPictures.PictureCamera
{
/// <summary>
/// Attached to the viewfinder UI prefab. Handles tap detection and other viewfinder-specific operations.
/// Also exposes screenshot-related references for the diving minigame.
/// </summary>
public class Viewfinder : MonoBehaviour, ITouchInputConsumer
{
[SerializeField]
private Image[] viewfinderImages; // Array of Image components to tint based on proximity
[Header("Screenshot Components")]
[FormerlySerializedAs("_captureArea")]
[SerializeField] private RectTransform captureArea;
[FormerlySerializedAs("_flyawayAnimation")]
[SerializeField] private ScreenshotFlyawayAnimation flyawayAnimation;
[Header("UI Elements to Hide During Screenshot")]
[Tooltip("UI elements (like frame, crosshairs) that should be hidden during screenshot capture")]
[SerializeField] private GameObject[] uiElementsToHideDuringCapture;
// Events
public event System.Action OnViewfinderTapped;
public event System.Action OnViewfinderHoldStarted;
@@ -24,9 +37,41 @@ namespace Minigames.DivingForPictures.PictureCamera
private RectTransform _rectTransform;
private CameraViewfinderManager _viewfinderManager;
// Public properties for screenshot system
public RectTransform CaptureArea
{
get
{
if (captureArea == null)
{
captureArea = GetComponent<RectTransform>();
}
return captureArea;
}
}
public ScreenshotFlyawayAnimation FlyawayAnimation => flyawayAnimation;
/// <summary>
/// UI elements to hide during screenshot capture (frame, crosshairs, etc.)
/// </summary>
public GameObject[] UIElementsToHideDuringCapture => uiElementsToHideDuringCapture;
private void Awake()
{
_rectTransform = GetComponent<RectTransform>();
// Auto-assign capture area to self if not set
if (captureArea == null)
{
captureArea = GetComponent<RectTransform>();
}
// Auto-find flyaway animation in children
if (flyawayAnimation == null)
{
flyawayAnimation = GetComponentInChildren<ScreenshotFlyawayAnimation>(includeInactive: true);
}
}
/// <summary>