37 lines
724 B
C#
37 lines
724 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace DefaultNamespace
|
|
{
|
|
public class FireButton : MonoBehaviour
|
|
{
|
|
[SerializeField] private InputAction _inputAction;
|
|
|
|
private bool _isPressed;
|
|
|
|
private void OnEnable()
|
|
{
|
|
_inputAction.Enable();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_inputAction.Disable();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_isPressed = _isPressed || _inputAction.triggered;
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
if (_isPressed)
|
|
{
|
|
_isPressed = false;
|
|
// spawn bullet
|
|
}
|
|
}
|
|
}
|
|
} |