Unity3D 让物体跟着手指移动 for ios、android
在unity for iphone中,为了让物体跟着我的手指移动,要转换坐标,但是进不了最后一个if,不知道问题出在哪,请大家帮我看看。这是我的代码var buttonForSFX: GUITexture;
if (iPhoneInput.touchCount > 0 && buttonForSFX.HitTest(iPhoneInput.GetTouch(0).position))
{
if (iPhoneInput.GetTouch(0).phase == iPhoneTouchPhase.Moved)
{
if(iPhoneInput.GetTouch(0).position.x <= 338 && iPhoneInput.GetTouch(0).position.x >= 127)
{
var hit: RaycastHit;
var sfxRay: Ray = Camera.main.ScreenPointToRay (iPhoneInput.GetTouch(0).position);
if (Physics.Raycast(sfxRay,hit,1000))
{
print("hit point" + hit.point.x);
buttonForSFX.transform.position.x = hit.point.x;
}
}
}
楼主是超人 顶顶多好 难得一见的好帖 说的非常好 LZ真是人才 好帖就是要顶 顶顶多好 很好哦 不错不错