CamRotate.cs 620 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. using System.Collections;
  3. public class CamRotate : MonoBehaviour {
  4. private bool roate;
  5. private float RoatedSpeed = 1000.0F;
  6. void Start () {
  7. roate = false;
  8. }
  9. // Update is called once per frame
  10. void Update () {
  11. if(Input.GetMouseButton(0))
  12. {
  13. float y = 0;
  14. y = Input.GetAxis("Mouse X")*RoatedSpeed*Time.deltaTime;
  15. if(roate)
  16. {
  17. gameObject.transform.Rotate(new Vector3(0,y,0));
  18. }
  19. }
  20. }
  21. void OnMouseDown()
  22. {
  23. roate =true;
  24. Debug.Log("collider");
  25. }
  26. void OnMouseUp()
  27. {
  28. roate = false;
  29. Debug.Log("Out of collider");
  30. }
  31. }