Advertisement
Darkhitori

vInput/GetAxisButtonUp

Jan 12th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vInput")]
  10.     [Tooltip("Get Axis like a buttonUp Check if Axis is zero after press ")]
  11.     public class vI_GetAxisButtonUp : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vInput))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         [ActionSection("Return")]
  18.         [UIHint(UIHint.FsmBool)]
  19.         public FsmBool getAxisButtonUp;
  20.        
  21.         [ActionSection("Event")]
  22.         public FsmEvent sendEvent;
  23.        
  24.         public FsmBool everyFrame;
  25.  
  26.         GenericInput theScript;
  27.  
  28.  
  29.         public override void Reset()
  30.         {
  31.             gameObject = null;
  32.             sendEvent = null;
  33.             getAxisButtonUp = false;
  34.             everyFrame = true;
  35.         }
  36.        
  37.         public override void OnEnter()
  38.         {
  39.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  40.  
  41.             theScript = go.GetComponent<GenericInput>();
  42.  
  43.  
  44.             if (!everyFrame.Value)
  45.             {
  46.                 DoTheMagic();
  47.                 Finish();
  48.             }
  49.  
  50.         }
  51.  
  52.         public override void OnUpdate()
  53.         {
  54.             if (everyFrame.Value)
  55.             {
  56.                 DoTheMagic();
  57.             }
  58.         }
  59.  
  60.         void DoTheMagic()
  61.         {
  62.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  63.             if (go == null)
  64.             {
  65.                 return;
  66.             }
  67.  
  68.             getAxisButtonUp.Value = theScript.GetAxisButtonUp();
  69.             if (getAxisButtonUp.Value)
  70.             {
  71.                 Fsm.Event(sendEvent);
  72.             }
  73.         }
  74.  
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement