Rasagar/Library/PackageCache/com.unity.cinemachine/Samples~/Cinemachine Example Scenes/Scenes/3rdPersonWithAimMode/ActivateOnKeypress.cs

46 lines
1.2 KiB
C#
Raw Normal View History

2024-08-26 13:07:20 -07:00
using UnityEngine;
namespace Cinemachine.Examples
{
public class ActivateOnKeypress : MonoBehaviour
{
public KeyCode ActivationKey = KeyCode.LeftControl;
public int PriorityBoostAmount = 10;
public GameObject Reticle;
Cinemachine.CinemachineVirtualCameraBase vcam;
bool boosted = false;
void Start()
{
vcam = GetComponent<Cinemachine.CinemachineVirtualCameraBase>();
}
void Update()
{
#if ENABLE_LEGACY_INPUT_MANAGER
if (vcam != null)
{
if (Input.GetKey(ActivationKey))
{
if (!boosted)
{
vcam.Priority += PriorityBoostAmount;
boosted = true;
}
}
else if (boosted)
{
vcam.Priority -= PriorityBoostAmount;
boosted = false;
}
}
if (Reticle != null)
Reticle.SetActive(boosted);
#else
InputSystemHelper.EnableBackendsWarningMessage();
#endif
}
}
}