Audio Source Loop#
Audio / Audio Source / Audio Source Loop
Can Read
Can Write
Description#
The Loop 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 Loop")]
[Category("Audio/Audio Source/Loop")]
[Description("The Loop property of the Audio Source component")]
[Image(typeof(IconAudioSource), ColorTheme.Type.Yellow)]
[Keywords("Audio, Sound, Music, Ambient, Sfx")]
[Serializable]
public class GenTypeBool_AudioSource_Loop : TypeBool
{
[SerializeField] private GetGameObject m_AudioSource = new GetGameObject(
new GenTypeGameObject_AudioSource()
);
public override bool GetPreview(GameObject source)
{
GameObject instance = this.m_AudioSource.GetPreview(source);
if (instance == null) return default;
AudioSource component = instance.GetComponent<AudioSource>();
return component != null ? component.loop : default;
}
public override bool Get(Args args)
{
AudioSource instance = this.m_AudioSource.Get<AudioSource>(args);
return instance != null
? instance.loop
: default;
}
public override void Set(bool value, Args args)
{
AudioSource component = this.m_AudioSource.Get<AudioSource>(args);
if (component != null) component.loop = (bool) value;
}
public override string ToString()
{
return $"{this.m_AudioSource} Loop";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}