Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#
Removed

AvailableData

struct in UnityEngine.Audio

/

Implemented in:UnityEngine.AudioModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete Types with embedded references are not supported in this version of your compiler.

Description

A temporary collection of data available for enumeration.

You can enumerate the Elements within using a foreach loop over this collection.

Additional resources: ControlContext.SendData, Pipe.SendData

using System;
using UnityEngine.Audio;
using static UnityEngine.Audio.ProcessorInstance;
using static UnityEngine.Audio.GeneratorInstance;
using Unity.IntegerTime;

class AvailableDataExamples { struct ThingToCommunicate { public float MyData; }

struct OtherThing { public int MyOtherData; }

internal struct ProcessorInvestigatingData : GeneratorInstance.IRealtime { public void Update(UpdatedDataContext context, Pipe pipe) { float myData = 0f;

foreach (var element in pipe.GetAvailableData(context)) { if (element.TryGetData(out ThingToCommunicate thing)) { myData = thing.MyData; } else if (element.TryGetData(out OtherThing otherThing)) { myData = MathF.PI * otherThing.MyOtherData; } } }

internal struct Control : GeneratorInstance.IControl<ProcessorInvestigatingData> { public void Update(ControlContext context, Pipe pipe) { float myData = 0f;

foreach (var element in pipe.GetAvailableData(context)) { if (element.TryGetData(out ThingToCommunicate thing)) { myData = thing.MyData; } else if (element.TryGetData(out OtherThing otherThing)) { myData = MathF.PI * otherThing.MyOtherData; } } }

public void Dispose(ControlContext context, ref ProcessorInvestigatingData processor) { }

public ProcessorInstance.Response OnMessage(ControlContext context, Pipe pipe, Message message) => ProcessorInstance.Response.Unhandled;

public void Configure(ControlContext context, ref ProcessorInvestigatingData processor, in AudioFormat format, out Setup setup, ref Properties properties) => setup = new(format); }

public bool isFinite => false; public bool isRealtime => false; public DiscreteTime? length => null; public Result Process(in RealtimeContext ctx, Pipe pipe, ChannelBuffer buf, Arguments args) => 0; } }