public void OnClickMoveButtonRight(bool isDown) { if (isDown) { m_DButton.Pressed(); } else { m_DButton.Released(); } }
void Update() { //Release the shake button if it was pressed last frame - this is only necessary to allow us to press the button again if (shakeButton.GetButton) { shakeButton.Released(); } //only check if the setting is enabled if (PlayerPrefs.GetInt("ShakeEnabled") == 1) { //Get the change in acceleration this frame float verticalAcceleration = Input.acceleration.y; float verticalAccelerationDelta = verticalAcceleration - prevVerticalAcceleration; //Make sure the delta is frame rate independent verticalAccelerationDelta *= (Time.deltaTime * expectedFps); //Use setting to determine shake threshold float shakeDetectThreshold = Mathf.Lerp(minShakeDetectThreshold, maxShakeDetectThreshold, PlayerPrefs.GetFloat("ShakeSensitivity", 0.5f)); //Check if we have exceeded the acceleration threshold if (Mathf.Abs(verticalAccelerationDelta) >= shakeDetectThreshold) { bool shakingForward = IsShakeForward(verticalAccelerationDelta); //Check if this shake is continuing a previous shake if (Time.time - prevShakeTime <= shakeDetectInterval) { //We are continuing a previous shake so it only adds to the streak counter if the shake direction has been reversed if (prevShakeForward != shakingForward) { if (++currentShakeStreak >= requiredShakes) { shakeButton.Pressed(); currentShakeStreak = 0; } } } //Otherwise start a new shake streak else { currentShakeStreak = 1; } //Record the shake values for future comparison prevShakeTime = Time.time; prevShakeForward = shakingForward; } //Record the acceleration value for future comparison prevVerticalAcceleration = verticalAcceleration; } }
// Update is called once per frame void Update() { UpdateAxis(ref m_HAxis, isLeftON, isRightON, hSpeed); UpdateAxis(ref m_VAxis, isDownON, isUpON, vSpeed); if (isResetON) { m_ResetButton.Pressed(); m_ResetButton.Released(); isResetON = false; isLeftON = false; isRightON = false; isUpON = false; isDownON = false; } }
void Update() { //Test every touch against the left/right trigger input areas to determine if buttons have been pressed or released for (var i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); if (touch.phase == TouchPhase.Began) { if (leftButtonArea.Contains(touch.position)) { leftButton.Pressed(); leftButtonFingerId = touch.fingerId; } if (rightButtonArea.Contains(touch.position)) { rightButton.Pressed(); rightButtonFingerId = touch.fingerId; } } if (touch.fingerId == leftButtonFingerId) { leftButton.Update(touch.position); if (touch.phase == TouchPhase.Ended) { leftButton.Released(); leftButtonFingerId = -1; } } if (touch.fingerId == rightButtonFingerId) { rightButton.Update(touch.position); if (touch.phase == TouchPhase.Ended) { rightButton.Released(); rightButtonFingerId = -1; } } } }
public void OnPointerDown(PointerEventData data) { m_VirtualButton.Pressed(); }
public void OnPointerDown(PointerEventData data) { myBt.Pressed(); Debug.Log("clicks " + data.pointerId + ": " + data.clickCount); }
public void OnPointerDown(PointerEventData data) { //CrossPlatformInputManager.SetButtonDown(Name); myBt.Pressed(); }