public override void OnInspectorGUI() { base.OnInspectorGUI(); if (GUILayout.Button("Preview Sound")) { if (_soundClipSO.Clip != null) { ClearPreviewAudioSource(); _audioSource = new GameObject("Sound Preview").AddComponent <AudioSource>(); _audioSource.gameObject.hideFlags = HideFlags.HideAndDontSave; _soundClipSO.Play(_audioSource); } } if (GUILayout.Button("Stop Preview")) { ClearPreviewAudioSource(); } }
public void PlaySound(SoundClipSO sound) { SaveCurrentPlaybackTime(); sound.Play(_audioSource, GetPlaybackTime(sound)); _currentClip = sound; }