Hi,
like this fsm action or hear is link
http://forum.unity3d.com/threads/123270-Aperture-Cutscene-Editor-RELEASED/page2 using System;
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Animation)]
[Tooltip("Plays an Aperture Cutscene on a Game Object.")]
public class PlayApertureCutscene : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(Cutscene))]
[Tooltip("Game Object which has a cutscene.")]
public FsmOwnerDefault gameObject;
[Tooltip("Event to send when the cutscene has finished playing. NOTE: Not sent with Loop mode!")]
public FsmEvent finishEvent;
[Tooltip("Event to send when the cutscene loops. If you want to send this event to another FSM use Set Event Target. NOTE: This event is only sent with Loop mode.")]
public FsmEvent loopEvent;
[Tooltip("Stop playing the cutscene when this state is exited.")]
public bool stopOnExit;
[Tooltip("Loop the cutscene.")]
public bool loopCutscene;
[Tooltip("Play the cutscene in reverse. Only works if the cutscene has already been played forwards by some amount.")]
public bool reverseCutscene;
public override void Reset()
{
gameObject = null;
finishEvent = null;
loopEvent = null;
stopOnExit = false;
loopCutscene = false;
reverseCutscene = false;
}
public override void OnEnter()
{
DoPlayCutscene();
}
void DoPlayCutscene()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
Finish();
return;
}
Cutscene thecutscene = go.GetComponent<Cutscene>();
if (thecutscene == null)
{
LogWarning("Missing cutscene component!");
Finish();
return;
}
if (loopCutscene)
{
thecutscene.loop = true;
}
else
{
thecutscene.loop = false;
}
if (reverseCutscene)
{
thecutscene.Rewind();
}
else
{
thecutscene.Play();
}
}
public override void OnUpdate()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
Cutscene thecutscene = go.GetComponent<Cutscene>();
if (thecutscene == null)
{
LogWarning("Missing cutscene component!");
Finish();
return;
}
if (!thecutscene.playing && !reverseCutscene)
{
Fsm.Event(finishEvent);
Finish();
}
if (reverseCutscene && (thecutscene.totalPlays == 0))
{
Fsm.Event(finishEvent);
Finish();
}
if (loopCutscene && (thecutscene.totalPlays > 1))
{
Fsm.Event(loopEvent);
}
}
public override void OnExit()
{
if (stopOnExit)
{
StopCutscene();
}
}
void StopCutscene()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go != null)
{
Cutscene thecutscene = go.GetComponent<Cutscene>();
if (thecutscene !=null)
{
thecutscene.Stop();
}
}
}
}
}