Advertisement
DugganSC

Untitled

Jun 18th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. public class PlaySound : MonoBehaviour
  2. {
  3. [SerializeField] AudioClip _clip;
  4. [SerializeField] AudioSource _source;
  5. [SerializeField] float _pitch = 1.0f;
  6. // Start is called before the first frame update
  7. void Start()
  8. {
  9. }
  10.  
  11. public void PlayKey()
  12. {
  13. _source.pitch = _pitch;
  14. Debug.Log($"Playing {_clip.name}", this);
  15. _source.PlayOneShot(_clip);
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement