[AddComponentMenu("NGUI/Examples/Spin With Mouse")]
publicclass SpinWithMouse : MonoBehaviour
{
publicTransform target;
public float speed = 1f;
Transform mTrans;
void Start ()
{
mTrans = transform;
}
void OnDrag (Vector2 delta)
{
//NUIG 鼠标或手机,点击事件为空。后再进行transform rotation
UICamera.currentTouch.clickNotification = UICamera.ClickNotification.None;
if (target != null)
{
target.localRotation = Quaternion.Euler(0f, -0.5f * delta.x * speed, 0f) * target.localRotation;
}
else
{
mTrans.localRotation = Quaternion.Euler(0f, -0.5f * delta.x * speed, 0f) * mTrans.localRotation;
}
}
}