Darkhitori

vHUDController/FadeText

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