eastbayeff

Untitled

Nov 24th, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3.  
  4. [System.Serializable]
  5. public class LaneHitEvent : UnityEvent<int> { }
  6.  
  7. public class Detector : MonoBehaviour
  8. {
  9.     public LaneHitEvent OnButtonPressed;
  10.  
  11.     private void Update()
  12.     {
  13.         if (Input.GetKeyDown(KeyCode.Alpha1))
  14.             OnButtonPressed.Invoke(1);
  15.  
  16.         if (Input.GetKeyDown(KeyCode.Alpha2))
  17.             OnButtonPressed.Invoke(2);
  18.  
  19.         if (Input.GetKeyDown(KeyCode.Alpha3))
  20.             OnButtonPressed.Invoke(3);
  21.  
  22.         if (Input.GetKeyDown(KeyCode.Alpha4))
  23.             OnButtonPressed.Invoke(4);
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment