- Home /
Play AudioSource in editor
I'm trying to write a tool to manage audio files for our game, and one of the features requested was the ability to audition (playback) AudioSource's attached to a prefab object in the editor (without having to launch the game). I've been trying to figure out a way to get this to work correctly but have been unsuccessful.
I've tried adding a new temporary node to the scene, and then creating a new AudioSource component to them, copying all the parameters from the prefab's version over, and then playing that - but I'm getting strange behaviour from some of the methods on the AudioSource (e.g. the 'isPlaying' never seems to go back to 'false'). The script that does the actual playback depends on the audio sources behaving as they do at runtime (since it's actually choosing which sources to play in a non-trivial manner), and I'm reluctant to re-write another seperate version just for the editor unless that's the only option.
I cannot use the static AudioSource.PlayClipAtPoint(...) method because I need to be able to apply pitch shifting and looping.
Has anyone attempted something like this before? If so, was there a way to get it working?