59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using Cinemachine;
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
using PMaker.DependencyInjection;
|
|
using PMaker.Extension;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using System.Threading;
|
|
|
|
using UnityEngine;
|
|
|
|
public class ControllerSwitcher : SingletonMonobehaviour
|
|
{
|
|
public FirstPersonLogic firstPersonLogic;
|
|
public CinemachineBrain brain;
|
|
|
|
public async UniTask WaitCameraCut(CancellationToken cancellationToken)
|
|
{
|
|
await brain.m_CameraCutEvent.OnInvokeAsync(cancellationToken);
|
|
}
|
|
|
|
private void Reset()
|
|
{
|
|
brain = this.GetComponentInChildren<CinemachineBrain>();
|
|
}
|
|
|
|
[Button]
|
|
public void SetPlayer(bool value)
|
|
{
|
|
firstPersonLogic.SetActive(value);
|
|
foreach (var item in this.transform.Children())
|
|
{
|
|
item.gameObject.SetActive(!value);
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void ResetCamera(bool value)
|
|
{
|
|
this.transform.Find("³õʼλÖÃ").gameObject.SetActive(value);
|
|
}
|
|
}
|
|
|
|
public static class BaseBehaviourExtensionControllerSwitcher
|
|
{
|
|
public static void SetPlayer(this BaseBehaviour baseBehaviour, bool value)
|
|
{
|
|
var controller = IoC.GetSingleton<ControllerSwitcher>();
|
|
controller.SetPlayer(value);
|
|
}
|
|
|
|
public static void ResetCamera(this BaseBehaviour baseBehaviour, bool value)
|
|
{
|
|
var controller = IoC.GetSingleton<ControllerSwitcher>();
|
|
controller.ResetCamera(value);
|
|
}
|
|
} |