Advertisement
Pro_Unit

EventAction

Mar 5th, 2021
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Events;
  4.  
  5. [Serializable]
  6. public  class EventAction
  7. {
  8.     [HideInInspector] [SerializeField] private string _name;
  9.  
  10.     public void OnValidate()
  11.     {
  12.         if (_animationEvent) _name = _animationEvent.name;
  13.     }
  14.  
  15.     [SerializeField] private AnimationEvent _animationEvent;
  16.     [SerializeField] protected UnityEvent  _event;
  17.     public void Invoke() => _event.Invoke();
  18.    
  19.     public static implicit operator int(EventAction eventAction)
  20.         => eventAction._animationEvent.GetInstanceID();
  21.    
  22.     public override string ToString() => _name;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement