As AudioSource.clip isn’t a reference to asset but a string, how would we go about changing it in runtime?.. edit: just figured audio files get put in the asset folder in project, so by name.type then?
by user 262331051802755072
As AudioSource.clip isn’t a reference to asset but a string, how would we go about changing it in runtime?.. edit: just figured audio files get put in the asset folder in project, so by name.type then?
by user 262331051802755072
By assigning it another url. When your component has an audioclip reference it gets serialized as a path and the file gets copied to the output directory
Same with videos
ok so just the name.filetype is not the way but file path
by user 262331051802755072
relative to the project?
by user 262331051802755072
Either relative to the project or absolute yes
You can assign it some external url too if that other server allows that
ok ok understood, thanks
by user 262331051802755072
how do I get the audio files to be included in the generated build (and in the generated project asset folder) if they need to be referenced by audiosources in editor to get included there?
by user 262331051802755072
Exactly, they need to be referenced by a component.
You can add a field or array and annotate it with @type UnityEngine.AudioClip for example to have the field be generated for e.g. a string
Or declare a type like: type AudioClip = string and then use that as your field type (e.g. “public myField : AudioClip;”
cool, will do Thanks!
by user 262331051802755072
it did get them to be included in the folder but I can’t play any that isn’t referenced by an audiosource to begin with…
by user 262331051802755072
let me ellaborate, I made the audioclip array, included 10 clips and only referenced the 6th in an audiosource, trying to set any from 1st to 5th by path won’t work, the 6th works, but 7th on don’t work either
by user 262331051802755072
Can you show the code that youre using for it?
are all of them mp3?
none are mp3 all of them wav
by user 262331051802755072
what is id:string ?