- Home /
Question by
thedodgeruk · Aug 17, 2012 at 08:52 AM ·
assign
I have a script and want to automaicly assign a sound
i have a script , which needs a audioclip. I want it to use the same clip every time. At the moment I have to make it public And then drag the sound onto it for ever prefab I do. I want the script to find the sound and assign it , how do I do that
Comment
Best Answer
Answer by Khada · Aug 17, 2012 at 05:23 PM
Create a 'Resources' folder inside your projects 'Assets' folder and place the audio file in there. Then in your script:
//variable to store audio clip
AudioClip clip = null;
//normal start method
void Start()
{
clip = (AudioClip)Resources.Load("filename");
}