Skip to content

Instantly share code, notes, and snippets.

@pacoelayudante
Created October 18, 2016 19:36
Show Gist options
  • Save pacoelayudante/8fb24bb72ebebd99870199e141878837 to your computer and use it in GitHub Desktop.
Save pacoelayudante/8fb24bb72ebebd99870199e141878837 to your computer and use it in GitHub Desktop.
Mirar con mouse si estas en editor o stand alone
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