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

31 lines
846 B
C#
Raw Normal View History

2023-08-23 01:59:40 +08:00
using System;
2023-06-08 14:09:50 +08:00
using UnityEngine;
using Cinemachine;
namespace BITKit
{
2023-08-23 01:59:40 +08:00
[Serializable]
public class CinemachineBasedAds:IProvider
{
public T Get<T>()
{
return CinemachineHelper.Singleton.Ads is T t? t : default;
}
}
2023-06-08 14:09:50 +08:00
public class CinemachineHelper : MonoBehaviour
{
2023-08-23 01:59:40 +08:00
internal static CinemachineHelper Singleton { get; private set; }
public float Ads { get; private set; }
2023-06-08 14:09:50 +08:00
public CinemachineBrain brain;
2023-08-23 01:59:40 +08:00
private void Awake()
{
Singleton = this;
}
private void FixedUpdate()
2023-06-08 14:09:50 +08:00
{
2023-10-31 18:07:15 +08:00
if (brain.ActiveVirtualCamera is not CinemachineVirtualCamera currentActive) return;
var currentFov = currentActive.m_Lens.FieldOfView;
Ads = currentFov / PlayerConfig.Singleton.Fov;
2023-06-08 14:09:50 +08:00
}
}
}