Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using FMODUnity;
- using FMOD;
- public class OpenDoor : MonoBehaviour
- {
- [SerializeField] EventReference OpenDoorSound;
- void Start()
- {
- EventManager.current.onDoorwayEnter += DoorwayEnter;
- }
- void DoorwayEnter()
- {
- AudioManager.instance.PlayOneShot(OpenDoorSound,transform.position);
- }
- public void OnMouseDown()
- {
- DoorwayEnter();
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using FMODUnity;
- public class AudioManager : MonoBehaviour
- {
- public static AudioManager instance {get; private set;}
- void Awake()
- {
- if (instance != null)
- {
- Debug.LogError("There are 2 audio managers in the scene.");
- }
- instance = this;
- }
- public void PlayOneShot(EventReference sound, Vector2 worldPos)
- {
- RuntimeManager.PlayOneShot(sound, worldPos);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement