Hi,
Ok, please find a updated play action that will accept all the different play functions. again it's blind coded, I don't own AudioToolkit yet, so tell me if that works as expected.
UPDATE: now with finished event, you can optionnaly set an event that will be fired with the audio reference finished playing.
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Audio toolkit")]
[Tooltip("Play an Audio item. Optionnaly send an event when autio item finished playing")]
public class AudioToolkitPlay : FsmStateAction
{
[RequiredField]
public FsmString reference;
public FsmVector3 worldPosition;
public FsmOwnerDefault parent;
public FsmFloat volume;
public FsmFloat delay;
public FsmFloat startTime;
public FsmEvent AudioCompletlyPlayedEvent;
public override void Reset()
{
reference = null;
worldPosition = null;
parent = null;
volume = 1f;
delay = 0f;
startTime = 0f;
AudioCompletlyPlayedEvent = null;
}
public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(parent);
AudioObject _obj;
if (go == null)
{
_obj = AudioController.Play(reference.Value,worldPosition.Value,volume.Value,delay.Value,startTime.Value);
}else{
_obj = AudioController.Play(reference.Value,worldPosition.Value,go.transform,volume.Value,delay.Value,startTime.Value);
}
if (AudioCompletlyPlayedEvent!=null)
{
_obj.completelyPlayedDelegate = OnAudioCompleteleyPlayed;
}
}
void OnAudioCompleteleyPlayed( AudioObject audioObj )
{
Debug.Log( "Finished playing " + audioObj.audioID + " with clip " + audioObj.audio.clip.name );
Fsm.Event(AudioCompletlyPlayedEvent);
Finish();
}
}
}
bye,
Jean