using UnityEngine; using System.Collections; using AX.MessageSystem; public abstract class MessageBehaviour : MonoBehaviour { public virtual string MessageType { get { return this.GetType().Name; } } protected virtual void OnDestroy() { MessageDispatcher.RemoveListener(MessageType, Execute); } protected virtual void OnEnable() { MessageDispatcher.AddListener(MessageType, Execute); } protected virtual void OnDisable() { MessageDispatcher.RemoveListener(MessageType, Execute); } protected abstract void Execute(IMessage message); }