Screenshots in Diving Minigame
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user