Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. namespace HutongGames.PlayMaker.Actions
  4. {
  5. //[ActionCategory(ActionCategory.Animation)]
  6. //OR
  7. //[ActionCategory("CATEGORY NAME")]
  8. [Tooltip("Tooltip for action goes here")]
  9. public class _ExampleAction : FsmStateAction {
  10.  
  11. [UIHint(UIHint.Variable)] //advanced: helps playmaker choose the most best editor for type of variable
  12. public FsmFloat exampleFloat; //using an "fsm" version of a variable allows you to subsitute in at runtime, if a variable type doesnt have one just use the normal version
  13.  
  14. [RequiredField] //makes a field required
  15. [Tooltip("Tooltip for variables go here")] //allows you to over variable name to see what its for
  16. public FsmEvent sendEvent; //used to broadcast an event to a fsm
  17.  
  18. public bool everyFrame;
  19.  
  20. //allows you to set default values for variables here when you use reset in the inspector
  21. public override void Reset()
  22. {
  23. everyFrame = false;
  24. }
  25.  
  26. public override void OnEnter()
  27. {
  28.  
  29. //a common addition to playmaker actions. this will allow the action to update more than once while the state it belongs to is active
  30. if (!everyFrame)
  31. Finish(); //stops OnUpdate() and runs OnExit()
  32. }
  33.  
  34. //run every frame the state the action belongs to is active and Finish() has not been called
  35. public override void OnUpdate()
  36. {
  37.  
  38. }
  39.  
  40. //run every frame AFTER OnUpdate(), same rules apply as above
  41. //tip: should be used instead of OnUpdate() if physics is involved
  42. public override void OnFixedUpdate()
  43. {
  44.  
  45. }
  46.  
  47. //run every frame AFTER OnUpdate(), same rules apply as above
  48. public override void OnLateUpdate()
  49. {
  50.  
  51. }
  52.  
  53. //run when Finish() is called
  54. public override void OnExit()
  55. {
  56.  
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement