Unity Remote doesn't work well??

I am currently working on a program to drag and drop images on iPad. I use mySkin loaded mu images to work as the image loader.
I’m using the unity 3 and unity remote to test if my code works.
At first it does work, after some modification it isn’t working anymore, and I had the code redone as before modified but it’s not working!

Here’s the code I’m on :

var mySkin : GUISkin; var myLeft:float
= 0; var myTop:float = 0; var myWidth:float = 200; var
myHeight:float = 50;

var isDragging:boolean = false;

// Add this line
var myInventoryImg : Texture2D;

function OnGUI()
{
GUI.skin = mySkin;
if ( GUI.RepeatButton( Rect( myLeft, myTop,
myWidth, myHeight), “”, “Button Drag”)
&& Input.touchCount > 0 &&
Input.GetTouch(0).phase ==
TouchPhase.Moved) isDragging =
true;
if ( isDragging) { print (Input.touchCount);
var touchPosition : Vector2 =
Input.GetTouch(0).position; myLeft =
touchPosition.x - myWidth0.5; myTop
= Screen.height - (touchPosition.y + myHeight
0.5); } }

function Update(){
if(!(Input.touchCount > 0 &&
Input.GetTouch(0).phase ==
TouchPhase.Moved))
isDragging = false; }

Does anybody know what’s wrong with my code?? or is it the unity remote that is not working well???

The main thing wrong in your code is where your touch handling is.
It must never be in OnGUI as ongui is called many times per frame (actually for iOS/Android you should avoid OnGUI for anything but the main menu for performance reasons), instead the input handling should be in Update

Problem solved ,the problem is within the unity remote…After I build using xcode the problem never shows up again… :slight_smile: