Audio Source Priority#
Audio / Audio Source / Audio Source Priority
Can Read
Can Write
Description#
The Priority property of the Audio Source component
Code#
// <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 Priority")]
[Category("Audio/Audio Source/Priority")]
[Description("The Priority property of the Audio Source component")]
[Image(typeof(IconAudioSource), ColorTheme.Type.Yellow)]
[Keywords("Audio, Sound, Music, Ambient, Sfx")]
[Serializable]
public class GenTypeInteger_AudioSource_Priority : 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.priority : default;
}
public override double Get(Args args)
{
AudioSource instance = this.m_AudioSource.Get<AudioSource>(args);
return instance != null
? instance.priority
: default;
}
public override void Set(double value, Args args)
{
AudioSource component = this.m_AudioSource.Get<AudioSource>(args);
if (component != null) component.priority = (int) value;
}
public override string ToString()
{
return $"{this.m_AudioSource} Priority";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}