Use only one method to call multiple sounds

New to FMOD.

I have a trigger, which the player walks through to enter a different room, it’s a prefab and I’ve got several of this same prefab throughout the game.

I want to play a unique audio clip when the player passes through each door, but I would like to avoid creating a new script for every door.

I’ve had a look online and I can’t find/understand how to go about implementing what I want.

My Door Trigger

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

public class RoomTrigger : MonoBehaviour
{
    [SerializeField] private Vector2 camMinChange;
    [SerializeField] private Vector2 camMaxChange;

    [SerializeField] private Vector3 playerChange;

    [SerializeField] CameraFollow camFollow;


    private void Start()
    {
        camFollow = Camera.main.GetComponent<CameraFollow>();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.tag == "Player")
        {
            TransitionRoom(collision);
            AudioManager.instance.PlayOneShot(FMODEvents.instance.useDoorSound, this.transform.position);

        }

    }

    private void TransitionRoom(Collider2D collision)
    {
        
        camFollow.minPos += camMinChange;
        camFollow.maxPos += camMaxChange;

        collision.transform.position += playerChange;

    }
}

My Audio Manager

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;

public class AudioManager : MonoBehaviour
{
   public static AudioManager instance { get; private set; }


   private void Awake()
   {
       if(instance != null)
       {
           Debug.Log("there is more than one Audio Manager");

       }
       instance = this;
   }

   public void PlayOneShot(EventReference sound, Vector3 worldPos)
   {
       RuntimeManager.PlayOneShot(sound, worldPos);
   }

}

Storing all my sounds in this FMOD Events script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;

public class FMODEvents : MonoBehaviour
{

    [field: Header("Narration")]

    [field: SerializeField] public EventReference Narration00 { get; private set; }
    [field: SerializeField] public EventReference Narration111 { get; private set; }


    [field: Header("Room SFX")]

    [field: SerializeField] public EventReference useDoorSound { get; private set; }

    public static FMODEvents instance { get; private set; }

    // ensures there is only one of these in scene
    private void Awake()
    {

        if(instance != null)
        {
            Debug.Log("Too many 'FMOD Events' in here"); 
        }

        instance = this;
    }

}

Hey.
One solution that I’d try would be to declare a serialized private int variable called m_doorType (for example) in your door trigger script that you could manually change in each of your prefab instances. In your fmod event, you would trigger a different audio for each value of a global parameter called “doorType”, using the trigger behavior feature.
Then, returning to your door trigger script, you could use setPrameterByName("doorType", m_doorType); inside your OntriggerEnter2D method, just before calling the sfx with PlayOneShot().

Here’s an example :

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

public class RoomTrigger : MonoBehaviour
{
    [SerializeField] private Vector2 camMinChange;
    [SerializeField] private Vector2 camMaxChange;

    [SerializeField] private Vector3 playerChange;

    [SerializeField] CameraFollow camFollow;

    //Value to edit in the prefab's inspector
    [SerializeField] private int m_doorType;


    private void Start()
    {
        camFollow = Camera.main.GetComponent<CameraFollow>();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.tag == "Player")
        {
            TransitionRoom(collision);

            //Setting your event's global parameter depending on the int value of the current door
            FMODUnity.RuntimeManager.StudioSystem.setParameterByName("doorType", m_doorType);
    
            AudioManager.instance.PlayOneShot(FMODEvents.instance.useDoorSound, this.transform.position);

        }

    }

    private void TransitionRoom(Collider2D collision)
    {
        
        camFollow.minPos += camMinChange;
        camFollow.maxPos += camMaxChange;

        collision.transform.position += playerChange;

    }
}

The downside is that you’d have to manually edit your value for each instance of the prefab and it could be a bit time demanding if there are a lot of those in your game. Otherwise maybe there is a value that you could retrieve from the actual door script that would determine which door is being crossed, and then replace the m_doorType value by this one. That way, you wouldn’t need to tweak manually each of your prefab instances because it would automatically get the correct value by listening to the door script.