/// <summary> /// Update component /// </summary> public void Update(VirtualJoystick joystick, int id = 0) { // Determine whether the joystick is using a controller isUsingController = joystick.isUsingController; // Reset the axis position direction = Vector2.zero; // Update each axis xAxis.Update(joystick, id); yAxis.Update(joystick, id); // Update the button button.Update(joystick, id); // Set the position of the axis direction = new Vector2(xAxis, yAxis).normalized; if (isUsingController) { float h = Input.GetAxis("Controller " + (id + 1) + " " + controllerAnalog.ToString() + "X"); float v = Input.GetAxis("Controller " + (id + 1) + " " + controllerAnalog.ToString() + "Y"); direction = Vector2.ClampMagnitude(new Vector2(h, v), 1); } }
/// <summary> /// /// </summary> public override void UpdateInput() { // m_Axis.Update(m_Trigger > deadZone?m_Trigger:0.0f); // if (m_Trigger >= buttonThreshold) { m_Button.Pressed(); } else { m_Button.Released(); } }
private void UpdateVirtualAxes(Vector3 delta) { transform.position = new Vector3( m_StartPos.x + delta.x, m_StartPos.y + delta.y, m_StartPos.z + delta.z ); delta /= Range; if (m_UseHorizontalAxis) { m_HorizontalVirtualAxis.Update(delta.x); } if (m_UseVerticalAxis) { m_VerticalVirtualAxis.Update(delta.y); } }