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
Thanks!