@@ -15,11 +15,9 @@ public static class EventAggregator
1515 /// </summary>
1616 /// <typeparam name="T">The type of event being listened for.</typeparam>
1717 /// <param name="obj"></param>
18- public static void Register < T > ( this T obj ) where T : struct
18+ public static void Register < T > ( this object obj )
1919 {
20- if ( ! _cache . ContainsKey ( typeof ( T ) ) )
21- _cache [ typeof ( T ) ] = new List < object > ( ) ;
22-
20+ if ( ! _cache . ContainsKey ( typeof ( T ) ) ) _cache [ typeof ( T ) ] = new List < object > ( ) ;
2321 _cache [ typeof ( T ) ] . Add ( obj ) ;
2422 }
2523
@@ -28,7 +26,7 @@ public static void Register<T>(this T obj) where T : struct
2826 /// </summary>
2927 /// <typeparam name="T">The type of event to no longer listen for.</typeparam>
3028 /// <param name="obj"></param>
31- public static void UnRegister < T > ( this T obj ) where T : struct
29+ public static void UnRegister < T > ( this object obj )
3230 {
3331 if ( ! _cache . ContainsKey ( typeof ( T ) ) ) return ;
3432 _cache [ typeof ( T ) ] . Remove ( obj ) ;
@@ -65,7 +63,7 @@ public static void UnRegister(object obj, Type listener)
6563 /// </summary>
6664 /// <typeparam name="T">The type of event being notified.</typeparam>
6765 /// <param name="message"></param>
68- public static void SendMessage < T > ( T message ) where T : struct
66+ public static void SendMessage < T > ( T message )
6967 {
7068 _cache [ message . GetType ( ) ] . Each ( x => ( ( IListener < T > ) x ) . Handle ( message ) ) ;
7169 }
@@ -74,7 +72,7 @@ public static void SendMessage<T>(T message) where T : struct
7472 /// Creates the cache for objects that listen to each event
7573 /// </summary>
7674 /// <typeparam name="T">Searches through all active GameObjects for those listening for event T and auto registers them.</typeparam>
77- public static void UpdateCache < T > ( ) where T : struct
75+ public static void UpdateCache < T > ( )
7876 {
7977 var type = typeof ( IListener < T > ) ;
8078 var list = new List < object > ( ) ;
0 commit comments