コード例 #1
0
        /// <summary>
        /// Process the Meta Button Event
        /// </summary>
        /// <param name="button">Button Message</param>
        public override void OnMetaButtonEvent(IMetaButton button)
        {
            Color targetColor = Color.white;

            switch (button.State)
            {
            case ButtonState.ButtonRelease:
                targetColor = _defaultColor;
                break;

            case ButtonState.ButtonShortPress:
                targetColor = Color.green;
                break;

            case ButtonState.ButtonLongPress:
                targetColor = Color.yellow;
                break;
            }

            for (int i = 0; i < _materials.Length; ++i)
            {
                var material = _materials[i];
                material.color = targetColor;
            }
        }
        /// <summary>
        /// Process the Meta Button Event
        /// </summary>
        /// <param name="button">Button Message</param>
        public void OnMetaButtonEvent(IMetaButton button)
        {
            if (button.Type != ButtonType.ButtonCamera)
            {
                return;
            }
            if (button.State != ButtonState.ButtonShortPress)
            {
                return;
            }
            if (!this.enabled)
            {
                Debug.LogWarning("Script is not enabled");
                return;
            }
            if (!CreateWebCamTexture())
            {
                Debug.LogWarning("Could not create Webcam Texture");
                return;
            }
            if (_isProcessing)
            {
                Debug.LogWarning("Still processing data");
                return;
            }

            StartCoroutine(TakeStill());
        }
コード例 #3
0
 /// <summary>
 /// Send the event
 /// </summary>
 /// <param name="button">Button event</param>
 private void SendEvent(IMetaButton button)
 {
     if (_mainEvent != null)
     {
         _mainEvent.Invoke(button);
     }
 }
コード例 #4
0
 /// <summary>
 /// Process the button events
 /// </summary>
 /// <param name="button">Button event</param>
 protected override void ProcessButtonEvents(IMetaButton button)
 {
     if (_mainEvent == null)
     {
         return;
     }
     _mainEvent.Invoke(button);
 }
コード例 #5
0
        /// <summary>
        /// Broadcast to the children of the current GameObject
        /// </summary>
        /// <param name="button">Button event</param>
        private void BroadcastChildren(IMetaButton button)
        {
            var objects = GetComponentsInChildren <IOnMetaButtonEvent>();

            for (int i = 0; i < objects.Length; ++i)
            {
                objects[i].OnMetaButtonEvent(button);
            }
        }
コード例 #6
0
        /// <summary>
        /// Broadcast to all GameObjects in the scene
        /// </summary>
        /// <param name="button">Button event</param>
        private void BroadcastToAll(IMetaButton button)
        {
            var objects = GameObject.FindObjectsOfType <BaseMetaButtonInteractionObject>();

            for (int i = 0; i < objects.Length; ++i)
            {
                objects[i].OnMetaButtonEvent(button);
            }
        }
 /// <summary>
 /// Raise the Volume Down Event
 /// </summary>
 /// <param name="button">Button message</param>
 private void RaiseVolumeDownEvent(IMetaButton button)
 {
     if (!_enableVolumeDownEvents)
     {
         return;
     }
     if (_volumeDownEvent == null)
     {
         return;
     }
     _volumeDownEvent.Invoke(button);
 }
 /// <summary>
 /// Raise the Camera Button Event
 /// </summary>
 /// <param name="button">Button message</param>
 private void RaiseCameraEvent(IMetaButton button)
 {
     if (!_enableCameraEvents)
     {
         return;
     }
     if (_cameraEvent == null)
     {
         return;
     }
     _cameraEvent.Invoke(button);
 }
コード例 #9
0
        /// <summary>
        /// Process the Meta Button Event
        /// </summary>
        /// <param name="button">Button Message</param>
        public void OnMetaButtonEvent(IMetaButton button)
        {
            if (button.Type != _buttonType)
            {
                return;
            }
            if (button.State != _buttonState)
            {
                return;
            }

            _source.PlayOneShot(_clip);
        }
        /// <summary>
        /// Process the button events
        /// </summary>
        /// <param name="button">Button event</param>
        protected override void ProcessButtonEvents(IMetaButton button)
        {
            switch (button.Type)
            {
            case ButtonType.ButtonCamera:
                RaiseCameraEvent(button);
                break;

            case ButtonType.ButtonVolumeDown:
                RaiseVolumeDownEvent(button);
                break;

            case ButtonType.ButtonVolumeUp:
                RaiseVolumeUpEvent(button);
                break;
            }
        }
コード例 #11
0
        public void ProcessButtonEvent(IMetaButton button)
        {
            if (button.Type == ButtonType.ButtonCamera)
            {
                return;
            }

            switch (button.State)
            {
            case ButtonState.ButtonRelease:
                _update = false;
                break;

            case ButtonState.ButtonLongPress:
                _update = true;
                break;
            }
            _uiText.text = string.Format("Volume: {0:0.00}", AudioListener.volume);
        }
コード例 #12
0
        /// <summary>
        /// Calls the update loop to get new values from the localizer.
        /// </summary>
        private void Update()
        {
            IMetaButton buttonEvent = null;

            // Pull buttons until button queue is exhausted for this update.
            while ((buttonEvent = _interop.GetButtonEvent()) != null)
            {
                // Make sure we send a Release event
                if (buttonEvent.Type != _lastType && _lastState != ButtonState.ButtonRelease)
                {
                    var forceRelease = new MetaButton(_lastType, ButtonState.ButtonRelease, buttonEvent.Timestamp);
                    SendEvent(forceRelease);
                }
                SendEvent(buttonEvent);

                _lastType  = buttonEvent.Type;
                _lastState = buttonEvent.State;
            }
        }
コード例 #13
0
        /// <summary>
        /// Process the button events
        /// </summary>
        /// <param name="button">Button event</param>
        protected override void ProcessButtonEvents(IMetaButton button)
        {
            switch (_broadcastType)
            {
            case ButtonBroadcastType.None:
                break;

            case ButtonBroadcastType.Scene:
                BroadcastToAll(button);
                break;

            case ButtonBroadcastType.Children:
                BroadcastChildren(button);
                break;

            case ButtonBroadcastType.Parents:
                BroadcastParent(button);
                break;
            }
        }
コード例 #14
0
        /// <summary>
        /// Process the Meta Button Event
        /// </summary>
        /// <param name="button">Button Message</param>
        public void OnMetaButtonEvent(IMetaButton button)
        {
            if (button.Type == ButtonType.ButtonCamera)
            {
                return;
            }
            if (!this.enabled)
            {
                Debug.LogWarning("Script is not enabled");
                return;
            }
            if (button.Type == ButtonType.ButtonVolumeUp)
            {
                _currentDelta = _delta;
            }
            if (button.Type == ButtonType.ButtonVolumeDown)
            {
                _currentDelta = _delta * -1f;
            }


            switch (button.State)
            {
            case ButtonState.ButtonShortPress:
                UpdateVolume();
                break;

            case ButtonState.ButtonLongPress:
                _volumeCoroutine = StartCoroutine(UpdateRoutine());
                break;

            case ButtonState.ButtonRelease:
                if (_volumeCoroutine != null)
                {
                    StopCoroutine(_volumeCoroutine);
                    _volumeCoroutine = null;
                }
                break;
            }
        }
コード例 #15
0
 /// <summary>
 /// Process the Meta Button Event
 /// </summary>
 /// <param name="button">Button Message</param>
 public abstract void OnMetaButtonEvent(IMetaButton button);
コード例 #16
0
 /// <summary>
 /// Process the button events
 /// </summary>
 /// <param name="button">Button event</param>
 protected abstract void ProcessButtonEvents(IMetaButton button);