I'm trying to make an audio player in Unity.
I first created a ResourceManager, that has a
AudioClip[] array.
public class ResourceManager : MonoBehaviour
{
public AudioSource audioSrc;
public AudioClip[] clips;
private int trackNum = 0;
public void Awake()
{
audioSrc = GetComponent<AudioSource>();
audioSrc.Stop();
...omitted...
public void LoadClip()
{
audioSrc.clip = clips[trackNum];
}
}
So that they appear in the Clips drag-and-drop box.
However, I want to make the AudioClip array static in ResourceManager static, so other scripts (e.g. PlayPause.cs can access clips statically (via function calls).
But the problem is once I make clips static, the drag-and-drop for disappears.
Is there a way to fix that? Or are there some better design patterns? Thanks.

You can e.g. simply do
The alternative suggested is make the
ResourceManagera so called singleton like e.g.And then access everywhere
ReaourcesManager.Instance.ClipsOr a built-in alternative to the singleton is using
FindObjectOfTypeso any other script in the Scene can actually simply accesswithout you having to change anything at all ;)
Except as said I would make it
depending a bit of course what exactly you want to do with the clips but this way the array can not be altered by any other script