Working screen anchoring

This commit is contained in:
Michal Pikulski
2025-10-13 16:31:52 +02:00
parent a55ba5e29c
commit 0b966e9976
9 changed files with 436 additions and 92 deletions

View File

@@ -1,5 +1,6 @@
using UnityEngine;
using Unity.Cinemachine;
using System;
namespace AppleHillsCamera
{
@@ -17,6 +18,9 @@ namespace AppleHillsCamera
[Tooltip("Whether to adjust the camera automatically when the screen size changes")]
public bool adjustOnScreenResize = true;
// Event that other components can subscribe to when camera is adjusted
public event Action OnCameraAdjusted;
private Camera _regularCamera;
private CinemachineCamera _virtualCamera;
@@ -104,8 +108,20 @@ namespace AppleHillsCamera
else
{
Debug.LogWarning("CameraScreenAdapter: Regular camera is not in orthographic mode.");
return;
}
}
// Notify subscribers that the camera has been adjusted
OnCameraAdjusted?.Invoke();
}
/// <summary>
/// Gets the camera component being controlled by this adapter
/// </summary>
public Camera GetControlledCamera()
{
return _usingCinemachine ? _virtualCamera.GetComponent<Camera>() : _regularCamera;
}
}
}