More control for playing audio
See original GitHub issueIt’d be nice if there was more control over playing audio -
- when using ControlAudio, you can only select an AudioSource to play, you cant select an AudioClip to play with said AudioSource
- when using PlayMusic/Sound/etc you can only select AudioClip, you cannot select AudioSource. These use the MusicManager which creates(?) or uses(?) an existing AudioSource, but you cannot specify which one you want it to use.
It’d be nice if there was a way to add an AudioClip to ControlAudio, so that one can select both the AudioSource and AudioClip to play. Right now, if one wants to have more control over AudioSources Fungus uses to play audio through, the workaround is using different AudioSources for different AudioClips which is not great.
To temporarily bridge this problem, I have added the following modifications to ControlAudio.cs:
protected SerializedProperty audioClipProp;
to line 17,
audioClipProp = serializedObject.FindProperty("_audioClip");
to line 29,
EditorGUILayout.PropertyField(audioClipProp);
to line 38
(these make it so the AudioClip field appears in the interface as per my screenshot attached)
then in ControlAudio.cs I added,
[SerializeField] protected AudioClip _audioClip;
in the initial declarations, then every time the _audioSource is played, I pasted this line above it; _audioSource.Value.clip = _audioClip;
ideally there should be a better solution to this that is cleaner, but this is my current workaround to it. Hope this is helpful
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top GitHub Comments
Re; type of variable; Both, makes it more flexible for Fungus to use say an AudioMixerGroupData to allow an object from a FungusVariable or directly dragged in from scene.
Not a fork, assuming all goes well, I expect this set of items to be in the next version of Fungus (3.14).
Thank you, I’ll pull it in a short bit!