---
tags:
    - "Audio, Sound, Music, Ambient, Sfx"
---

# Audio Source Volume

[Audio](../index.md) / [Audio Source](index.md) / **Audio Source Volume**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :green_circle: Can Write

</div>

## Description

The Volume property of the Audio Source component

## Code

```cs
// <auto-generated>
// This script was automatically generated using the Visual Script Transpiler.
// Do not modify. Changes to this file will be lost when updating the package.
// </auto-generated>

using System;
using UnityEngine;
using VisualScript.Icons;
using UnityEngine.Audio;

namespace VisualScript.Runtime
{
    [Get]
    [Set]

    [Title("Audio Source Volume")]
    [Category("Audio/Audio Source/Volume")]
    [Description("The Volume property of the Audio Source component")]

    [Image(typeof(IconAudioSource), ColorTheme.Type.Yellow)]
    [Keywords("Audio, Sound, Music, Ambient, Sfx")]

    [Serializable]
    public class GenTypeNumber_AudioSource_Volume : TypeNumber
    {
        [SerializeField] private GetGameObject m_AudioSource = new GetGameObject(
            new GenTypeGameObject_AudioSource()
        );

        public override double GetPreview(GameObject source)
        {
            GameObject instance = this.m_AudioSource.GetPreview(source);
            if (instance == null) return default;

            AudioSource component = instance.GetComponent<AudioSource>();
            return component != null ? component.volume : default;
        }

        public override double Get(Args args)
        {
            AudioSource instance = this.m_AudioSource.Get<AudioSource>(args);
            return instance != null
                ? instance.volume
                : default;
        }

        public override void Set(double value, Args args)
        {
            AudioSource component = this.m_AudioSource.Get<AudioSource>(args);
            if (component != null) component.volume = (float) value;
        }

        public override string ToString()
        {
            return $"{this.m_AudioSource} Volume";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
```

