Advertisement
Guest User

Untitled

a guest
Aug 26th, 2023
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using FMODUnity;
  5. using FMOD;
  6.  
  7. public class OpenDoor : MonoBehaviour
  8. {
  9. [SerializeField] EventReference OpenDoorSound;
  10. void Start()
  11. {
  12. EventManager.current.onDoorwayEnter += DoorwayEnter;
  13.  
  14. }
  15.  
  16. void DoorwayEnter()
  17. {
  18.  
  19. AudioManager.instance.PlayOneShot(OpenDoorSound,transform.position);
  20.  
  21.  
  22. }
  23.  
  24.  
  25. public void OnMouseDown()
  26. {
  27.  
  28. DoorwayEnter();
  29.  
  30.  
  31. }
  32.  
  33. }
  34.  
  35.  
  36.  
  37. using System.Collections;
  38. using System.Collections.Generic;
  39. using UnityEngine;
  40. using FMODUnity;
  41.  
  42. public class AudioManager : MonoBehaviour
  43. {
  44.  
  45. public static AudioManager instance {get; private set;}
  46.  
  47. void Awake()
  48. {
  49. if (instance != null)
  50. {
  51.  
  52. Debug.LogError("There are 2 audio managers in the scene.");
  53. }
  54. instance = this;
  55.  
  56. }
  57.  
  58. public void PlayOneShot(EventReference sound, Vector2 worldPos)
  59. {
  60.  
  61. RuntimeManager.PlayOneShot(sound, worldPos);
  62.  
  63. }
  64.  
  65.  
  66. }
  67.  
  68.  
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement