Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

AvailableData

struct in UnityEngine.Audio

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

Description

A temporary collection of data available for enumeration.

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

Additional resources: 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; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961