November 2019
Intermediate to advanced
404 pages
12h 9m
English
Let's define our messaging system by deriving from the SingletonComponent class and provide a method for objects to register with it:
using System.Collections.Generic;using UnityEngine;public class MessagingSystem : SingletonComponent<MessagingSystem> { public static MessagingSystem Instance { get { return ((MessagingSystem)_Instance); } set { _Instance = value; } } private Dictionary<string,List<MessageHandlerDelegate>> _listenerDict = new Dictionary<string,List<MessageHandlerDelegate>>(); public bool AttachListener(System.Type type, MessageHandlerDelegate handler) { if (type == null) { Debug.Log("MessagingSystem: AttachListener failed due to having no " + "message type specified"); return false; } string ...Read now
Unlock full access