How do I access a static function in JS?

At least that’s what I think I want. Really , I want to be able to access a function without the need to attach my script (in which the function is defined) to a Game Object.

In my scenario I want an audio manager class to be accessed from multiple scripts within my project without the need to create an Audio Manager gameobject and then do a GameObject.Find…etc in every script.

Now I thought this should be pretty straightforward form all the examples I read but I just get errors. I have tried creating the following script:

public class audio_manager
{
 function PlayAudio()
 {
 //do stuff
 }
}

…and then in another script doing audio_manager.PlayAudio(); but this doesn’t work. So what is the simplest way to access this function?

P.S> I read many attempts to explain this with Singletons and C# but non of those examples are simple enough for my small mind. Shortest correct answer wins :wink:

Thanks!

static function PlayAudio()

EDIT: answer was short as you requested, but I decided to expand it a bit :slight_smile:

Marking a method as static means not only availability to access it without creating instance of your class. It also means, that you can’t access any instance methods or variables withing your script. So remember that static is not appropriate in all the cases.