Unity3d NGUI 360度旋转

[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;

}

}

}

posted @ 2013-07-08 11:38  韦斯利yx  阅读(1468)  评论(0编辑  收藏  举报