Advertisement
Pro_Unit

GameEventListenerTemplate

Mar 2nd, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using GameCore;
  2.  
  3. using System;
  4.  
  5. using UnityEngine;
  6. using UnityEngine.Events;
  7.  
  8. namespace $NAMESPACE_NAME$
  9. {
  10.    
  11.     public class GameEventListener$TYPE_NAME$ : MonoBehaviour
  12.     {
  13.         [SerializeField] GameEvent$TYPE_NAME$ Event;
  14.  
  15.         [SerializeField] UnityEvent$TYPE_NAME$ Responce;
  16.        
  17.         [SerializeField] bool debug;
  18.  
  19.         public void OnEventRaised ($TYPE_NAME$ arg)
  20.         {
  21.              if (debug)
  22.                 Debug.Log ($"{("OnEvent".a())} {$"[{Event.name}]".so()}\n{arg.ToString().cyan()}\n{("Raised On".a())} {name.mb()}", this);
  23.             Responce.Invoke (arg);
  24.         }
  25.         public void OnEnable ()
  26.         {
  27.             Event.RegisterListener (this);
  28.         }
  29.  
  30.         public void OnDisable ()
  31.         {
  32.             Event.UnRegisterListener (this);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement