using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class InputHandler : MonoBehaviour { #region Singleton public static InputHandler instance; private void Awake() { if (instance == null) instance = this; else if (instance != this) Destroy(gameObject); //DontDestroyOnLoad(gameObject); } #endregion public UnityEvent LeftMouseButtonPressed; public UnityEvent LeftMouseButtonReleased; public UnityEvent RightMouseButtonPressed; public UnityEvent RightMouseButtonReleased; public GameEventFloat SpellPressed; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { #region LeftMouseButton if (Input.GetMouseButtonDown(0)) { LeftMouseButtonPressed.Invoke(); } if (Input.GetMouseButtonUp(0)) { LeftMouseButtonReleased.Invoke(); } #endregion #region RightMouseButton if (Input.GetMouseButtonDown(1)) { RightMouseButtonPressed.Invoke(); } if (Input.GetMouseButtonUp(1)) { RightMouseButtonReleased.Invoke(); } #endregion #region Spell1 if(Input.GetKeyDown(KeyCode.Alpha1)) { SpellPressed.Raise(1); } #endregion #region Spell2 if(Input.GetKeyDown(KeyCode.Alpha2)) { SpellPressed.Raise(2); } #endregion } }