Example #1
0
        public void SubscribeToEvent <T>(AObject sender, NativeEventDelegate <T> eventDelegate) where T : NativeEventData
        {
            uint eventType = NativeEvents.GetEventID <T>();

            if (eventType == 0)
            {
                throw new InvalidOperationException("AObject.SubscribeToEvent<T>(EventDelegate<T> eventDelegate) - Unknown native event id");
            }

            // Move this
            NETCore.RegisterNETEventType(eventType);

            NativeEventHandlers[eventType] = (eventData) =>
            {
                eventDelegate((T)eventData);
            };

            if (sender != null)
            {
                NativeCore.SubscribeToEvent(this, sender, eventType);
            }
            else
            {
                NativeCore.SubscribeToEvent(this, eventType);
            }
        }
Example #2
0
        // Native events


        public void UnsubscribeFromEvent <T>() where T : NativeEventData
        {
            uint eventType = NativeEvents.GetEventID <T>();

            UnsubscribeFromEvent(eventType);
        }