private void UpdateVirtualAxes(float modifiedX, float modifiedY) { //update the relevant axes if (useX) { horizontalVirtualAxis.Update(modifiedX); } if (useY) { verticalVirtualAxis.Update(modifiedY); } }
void Update() { if (pairedWith == null) { FindPairedButton(); } pressedThisFrame = false; // check through all touches for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); // check that the touch is in the button position if (rect.Contains(touch.position)) { // update the axis and record that the button has been pressed this frame axis.Update(Mathf.MoveTowards(axis.GetValue, axisValue, responseSpeed * Time.deltaTime)); pressedThisFrame = true; } } }