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

36 lines
1.0 KiB
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; }
2023-06-08 14:09:50 +08:00
[SerializeReference, SubclassSelector] public References ads;
2023-08-23 01:59:40 +08:00
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
{
var playerConfig = Data.Get<PlayerConfig>();
var currentActive = brain.ActiveVirtualCamera as CinemachineVirtualCamera;
if (currentActive is not null && playerConfig is not null)
{
var currentFov = currentActive.m_Lens.FieldOfView;
2023-10-02 23:24:56 +08:00
Ads = currentFov / playerConfig.Fov;
2023-06-08 14:09:50 +08:00
}
}
}
}