- Home /
How do i add all the sounds for my character through a script, instead of using the Inspector?
Unity 5.3.5.
I want to just load sounds and play through a script that searches for the sound you give it, in the Assets folder's folder that you specify.
for example play(scream.mp3 from folder Assets/Human Sounds);
Is that possible to do ? or do you have to always have the sounds loaded into fields in the inspector tab.
Reason i'm want to do it like this is because i'm loading characters(planning and learning how)into scenes by script selecting random or particular characters. So it's not like i'm manually dragging the characters into the scene. Thanks for your help
Answer by Soraphis · Jun 16, 2016 at 06:27 PM
put all sounds in a folder Assets/Resources/YourFolderName
https://docs.unity3d.com/ScriptReference/Resources.Load.html
and load them via
var clip = Resources.Load("YourFolderName/YourClipName") as AudioClip;
Your answer
Follow this Question
Related Questions
Finding center of a cube 1 Answer
what is Vector3.normalized? 1 Answer
one or several scripts - what's better? 1 Answer
C#, "object reference not set to an instance of an object" 3 Answers
This doesnt work,help? 1 Answer