Class AudioCuePreview

Namespace
TDMaker.Editor
Assembly
TDMaker.Editor.dll

Previews AudioCues in the editor (edit mode or play mode) through one hidden AudioSource: a random clip and pitch per play, like AudioCuePlayer. Shared by inspectors and editor windows (the Audio section of authoring tools).

public static class AudioCuePreview
Inheritance
AudioCuePreview
Inherited Members

Properties

IsPlaying

Whether a preview is sounding.

public static bool IsPlaying { get; }

Property Value

bool

LastClip

The clip of the last preview, or null.

public static AudioClip LastClip { get; }

Property Value

AudioClip

Methods

DrawCueRow(string, AudioCue)

A row with a label, the clip count and Play / Stop buttons (layout).

public static void DrawCueRow(string label, AudioCue cue)

Parameters

label string
cue AudioCue

DrawSection(bool, string, IReadOnlyList<KeyValuePair<string, SerializedProperty>>)

An "Audio" section: a foldout header, then for each (label, cue property) the cue's property field followed by a preview row. Returns the new foldout state.

public static bool DrawSection(bool expanded, string title, IReadOnlyList<KeyValuePair<string, SerializedProperty>> cues)

Parameters

expanded bool
title string
cues IReadOnlyList<KeyValuePair<string, SerializedProperty>>

Returns

bool

FromProperty(SerializedProperty)

Reads an AudioCue from a serialized property (for previewing what an inspector shows).

public static AudioCue FromProperty(SerializedProperty cueProperty)

Parameters

cueProperty SerializedProperty

Returns

AudioCue

Play(AudioCue, float)

Plays one clip of cue (random clip and pitch). Returns false when the cue has no clip.

public static bool Play(AudioCue cue, float volumeScale = 1)

Parameters

cue AudioCue
volumeScale float

Returns

bool

PlayClip(AudioClip, float, float)

Plays a clip at a volume and pitch (stops the previous preview).

public static bool PlayClip(AudioClip clip, float volume = 1, float pitch = 1)

Parameters

clip AudioClip
volume float
pitch float

Returns

bool

Release()

Destroys the hidden preview object (call when a window that used previews closes).

public static void Release()

Stop()

Stops the preview.

public static void Stop()