using System.Collections; using System.Collections.Generic; using UnityEngine; public class Rotate : MonoBehaviour { private float mousePositionX=0; private bool inputMouse = false; private float speed=0.2f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { rotate(); } void rotate() { if (Input.GetMouseButtonDown(0)) { mousePositionX = Input.mousePosition.x; inputMouse = true; } if (inputMouse) { float Y = Input.mousePosition.x - mousePositionX; this.transform.eulerAngles += new Vector3(0, Y*speed, 0); mousePositionX = Input.mousePosition.x; } if (Input.GetMouseButtonUp(0)) { mousePositionX = 0; inputMouse = false; } } }