using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using FMOD.Studio;
using FMODUnity;
using UnityEngine;
using STOP_MODE = FMOD.Studio.STOP_MODE;

public class LoopySound : MonoBehaviour
{
    [SerializeField]
    [EventRef]
    private string _sfx;

    private EventInstance _sfxInstance;
    
    void Awake()
    {
        _sfxInstance = RuntimeManager.CreateInstance( _sfx );
        RuntimeManager.AttachInstanceToGameObject( _sfxInstance, transform, (Rigidbody)null );
    }

    private void OnEnable()
    {
        _sfxInstance.start();
    }

    private void OnDisable()
    {
        _sfxInstance.stop(STOP_MODE.IMMEDIATE);
    }
}
