void Start()
        {
            _pressable = GetComponent <PressableUI>();
            if (_pressable != null)
            {
                _pressable.OnPress.AddListener(DoOnPress);
                _pressable.OnRelease.AddListener(DoOnRelease);

                _pulsator = gameObject.AddComponent <Pulsator>();
                _pulsator.OnValueChanged += DoOnPulsatorValue;
                _pulsator._speed          = 5F;
            }
            else
            {
                Debug.LogWarning("[PressableButtonFeedback] GameObject lacks a PressableUI.");
            }
        }
Exemple #2
0
        private void InitMarbleTouch()
        {
            IndexUIActivator_PassTriggerEvents triggerEvents = _marbleCollider.GetComponent <IndexUIActivator_PassTriggerEvents>();

            if (triggerEvents == null)
            {
                triggerEvents = _marbleCollider.gameObject.AddComponent <IndexUIActivator_PassTriggerEvents>();
            }
            triggerEvents.PassedOnTriggerEnter.AddListener(NotifyFingerEnterMarble);
            triggerEvents.PassedOnTriggerExit.AddListener(NotifyFingerExitMarble);

            if (_marbleDepthCollider == null)
            {
                GameObject depthColliderObj = new GameObject();
                depthColliderObj.transform.parent        = _marbleCollider.transform.parent;
                depthColliderObj.transform.localRotation = Quaternion.Euler(new Vector3(90F, 0F, 0F));
                depthColliderObj.transform.localScale    = Vector3.one;
                depthColliderObj.name = "Marble Depth Touch Collider";

                _marbleDepthCollider           = depthColliderObj.AddComponent <CapsuleCollider>();
                _marbleDepthCollider.isTrigger = true;
                _marbleDepthCollider.radius    = 0.96F;
                _marbleDepthCollider.height    = 2.88F;
                _marbleDepthCollider.transform.localPosition = new Vector3(0F, 0F, -1.144F);
                triggerEvents = depthColliderObj.AddComponent <IndexUIActivator_PassTriggerEvents>();
                triggerEvents.PassedOnTriggerEnter.AddListener(NotifyFingerEnterDepthCollider);
                triggerEvents.PassedOnTriggerExit.AddListener(NotifyFingerExitDepthCollider);
            }

            if (_marblePulsator == null)
            {
                _marblePulsator                 = gameObject.AddComponent <Pulsator>();
                _marblePulsator._restValue      = 0F;
                _marblePulsator._pulseValue     = 0.4F;
                _marblePulsator._holdValue      = 0.15F;
                _marblePulsator._speed          = 2F;
                _marblePulsator.OnValueChanged += DoOnMarblePulsateValue;
            }
        }