/// <summary>
        /// Register to the button events
        /// </summary>
        private void OnEnable()
        {
            if (_registered)
            {
                return;
            }
            if (_provider == null)
            {
                var context = metaContext;
                if (context == null)
                {
                    Debug.LogWarning("Could not get Meta Context. Button events will not be provided");
                    return;
                }

                if (!context.ContainsModule <MetaButtonEventProvider>())
                {
                    Debug.LogWarning("Could not get Meta Button Event Provider. Button events will not be broadcasted");
                    return;
                }
                _provider = context.Get <MetaButtonEventProvider>();
            }

            _provider.Subscribe(ProcessButtonEvents);
            _registered = true;
        }
        /// <summary>
        /// Connect all the components in the childrens to the main Event Provider
        /// </summary>
        private void OnEnable()
        {
            if (_broadcaster == null)
            {
                _broadcaster = GetComponent <MetaButtonEventProvider>();
            }
            if (_controllers == null)
            {
                _controllers = GetComponentsInChildren <IOnMetaButtonEvent>();
            }

            for (int i = 0; i < _controllers.Length; ++i)
            {
                _broadcaster.Subscribe(_controllers[i].OnMetaButtonEvent);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Connect all the components in the childrens to the main Event Provider
        /// </summary>
        private void OnEnable()
        {
            _provider = GetButtonProvider();
            if (_provider == null)
            {
                return;
            }
            if (_controllers == null)
            {
                _controllers = FindObjectsOfType <MonoBehaviour>().OfType <IOnMetaButtonEvent>().ToArray();
            }

            for (int i = 0; i < _controllers.Length; ++i)
            {
                _provider.Subscribe(_controllers[i].OnMetaButtonEvent);
            }
        }
        /// <summary>
        /// Connect all the components in the childrens to the main Event Provider
        /// </summary>
        private void OnEnable()
        {
            _provider = GetButtonProvider();
            if (_provider == null)
            {
                return;
            }
            if (_controllers == null)
            {
                _controllers = GetComponentsInChildren <IOnMetaButtonEvent>();
            }

            for (int i = 0; i < _controllers.Length; ++i)
            {
                _provider.Subscribe(_controllers[i].OnMetaButtonEvent);
            }
        }