IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Audio/PlayAudioAtPosition.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

34 lines
849 B
C#

using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category("Audio")]
public class PlayAudioAtPosition : ActionTask<Transform>
{
[RequiredField]
public BBParameter<AudioClip> audioClip;
[SliderField(0, 1)]
public float volume = 1;
public bool waitActionFinish;
protected override string info {
get { return "PlayAudio " + audioClip.ToString(); }
}
protected override void OnExecute() {
AudioSource.PlayClipAtPoint(audioClip.value, agent.position, volume);
if ( !waitActionFinish )
EndAction();
}
protected override void OnUpdate() {
if ( elapsedTime >= audioClip.value.length )
EndAction();
}
}
}