CreateInstance(ControlContext, AudioFormat?, CreationParameters)
Factory method for creating a GeneratorInstance of this clip.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.AudioModule
public GeneratorInstance CreateInstance(ControlContext context, AudioFormat? nestedFormat, GeneratorInstance.CreationParameters creationParameters)
Parameters
The context in which the instance will be created.
If not null, the instance will be created with the the given format as nested, to be used from within another processor.
Initialization parameters passed through.
Returns
Type | Description |
|---|---|
| GeneratorInstance | Returns the generator instance of the clip. |
Remarks
Use this method to efficiently stream the AudioClip data as a GeneratorInstance. You can use the instance directly with a RealtimeContext or nest it within other GeneratorInstances to facilitate advanced playback behaviours. Note that you can only use persistent (imported) audio clips as generators. Runtime-created clips (via AudioClip.Create, DownloadHandlerAudioClip, or Microphone) throw a NotSupportedException.
Once an AudioClip has been used as a generator, AudioClip.GetData and AudioClip.SetData are permanently blocked for that clip instance.
Additional Resources: Using AudioClips as generators