PlayTransitionAction.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using FairyGUI.Utils;
  2. namespace FairyGUI
  3. {
  4. public class PlayTransitionAction : ControllerAction
  5. {
  6. public string transitionName;
  7. public int playTimes;
  8. public float delay;
  9. public bool stopOnExit;
  10. private Transition _currentTransition;
  11. public PlayTransitionAction()
  12. {
  13. playTimes = 1;
  14. delay = 0;
  15. }
  16. override protected void Enter(Controller controller)
  17. {
  18. Transition trans = controller.parent.GetTransition(transitionName);
  19. if (trans != null)
  20. {
  21. if (_currentTransition != null && _currentTransition.playing)
  22. trans.ChangePlayTimes(playTimes);
  23. else
  24. trans.Play(playTimes, delay, null);
  25. _currentTransition = trans;
  26. }
  27. }
  28. override protected void Leave(Controller controller)
  29. {
  30. if (stopOnExit && _currentTransition != null)
  31. {
  32. _currentTransition.Stop();
  33. _currentTransition = null;
  34. }
  35. }
  36. override public void Setup(ByteBuffer buffer)
  37. {
  38. base.Setup(buffer);
  39. transitionName = buffer.ReadS();
  40. playTimes = buffer.ReadInt();
  41. delay = buffer.ReadFloat();
  42. stopOnExit = buffer.ReadBool();
  43. }
  44. }
  45. }