BITFALL/Assets/BITKit/UnityPluginsSupport/Cinemachine/CinemachineHelper.cs

31 lines
846 B
C#

using System;
using UnityEngine;
using Cinemachine;
namespace BITKit
{
[Serializable]
public class CinemachineBasedAds:IProvider
{
public T Get<T>()
{
return CinemachineHelper.Singleton.Ads is T t? t : default;
}
}
public class CinemachineHelper : MonoBehaviour
{
internal static CinemachineHelper Singleton { get; private set; }
public float Ads { get; private set; }
public CinemachineBrain brain;
private void Awake()
{
Singleton = this;
}
private void FixedUpdate()
{
if (brain.ActiveVirtualCamera is not CinemachineVirtualCamera currentActive) return;
var currentFov = currentActive.m_Lens.FieldOfView;
Ads = currentFov / PlayerConfig.Singleton.Fov;
}
}
}