Created
October 18, 2016 19:36
-
-
Save pacoelayudante/8fb24bb72ebebd99870199e141878837 to your computer and use it in GitHub Desktop.
Mirar con mouse si estas en editor o stand alone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class MiraMouse : MonoBehaviour { | |
public float factorRotacion = 1; | |
#if UNITY_EDITOR || UNITY_STANDALONE | |
Vector2 prevPos; | |
void Awake() | |
{ | |
prevPos = Input.mousePosition; | |
} | |
void Update() | |
{ | |
if (Input.GetMouseButtonDown(0)) | |
{ | |
prevPos = Input.mousePosition; | |
} | |
else if(Input.GetMouseButton(0)) { | |
float dx = Input.mousePosition.x - prevPos.x; | |
float dy = Input.mousePosition.y - prevPos.y; | |
transform.Rotate(0, dx * factorRotacion, 0, Space.World); | |
transform.Rotate( -dy * factorRotacion, 0, 0); | |
prevPos = Input.mousePosition; | |
} | |
} | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment