Struct AudioSource | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Struct AudioSource

    An AudioSource component plays back one audio clip at a time.

    Namespace: Unity.Tiny.Audio
    Syntax
    public struct AudioSource : IComponentData
    Remarks

    Multiple audio sources can play at the same time. To start playback use the AudioSourceStart component. To stop playback use the AudioSourceStop component.

    clip, volume, and loop are read when the audio source starts as a result of AudioSourceStart being added. They will not change audio that is already playing.

    isPlaying is updated with every tick of the world.

    Fields

    clip

    Specifies the audio clip that plays when this source starts playing.

    Declaration
    [EntityWithComponents(new Type[]{typeof(AudioClip)})]
    public Entity clip
    Field Value
    Type Description
    Entity

    loop

    If true, replays the audio clip when it reaches end.

    Declaration
    public bool loop
    Field Value
    Type Description
    System.Boolean

    volume

    Specifies the audio clip's playback volume. Values can range from 0..1.

    Declaration
    public float volume
    Field Value
    Type Description
    System.Single

    Properties

    isPlaying

    True if the audio clip is currently playing.

    Declaration
    public bool isPlaying { get; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    isPlaying will start false, and will be false until the AudioSourceStart tag is removed by the Audio system.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023