URGENT!!! Dragging Toggle Problems

Need Help!!! I want to drag a toggle button and then when I released it somewhere the toggle turns on and another images loads up somewhere else…

I don’t know what’s wrong with my scripting…The code fails to compile and I couldn’t find anything’s wrong :frowning:

function OnGUI ()
{
	
	//setting up custom skin
	GUI.skin = mySkin;
	// title Unit number
		GUI.Label( Rect( 320, 95, 320 , 100), imageBox, mySkin.box);
//		touchPosition = Input.GetTouch(0).position;
		//Hero image 1
		but1 = GUI.Toggle( Rect( myLeft, myTop, myWidth, myHeight), !heroSelect1, "", "Hero1");
		
		//Hero 1 available check
		if ( but1 == true  Input.touchCount > 0  (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)  isDragging2 == false  heroSelect1 == false)
		{isDragging = true; isDragging2 = false;}
		
		//moves the hero image1
		if ( isDragging)
		{
		touchPosition = Input.GetTouch(0).position;
		myLeft = touchPosition.x - myWidth * 0.5;
		myTop = Screen.height - (touchPosition.y + myHeight * 0.5);
		}
//		if(heroSelect1 == true)
//		isDragging = false;
		
		//Hero Image 2
		but2 = GUI.Toggle ( Rect( myLeft2, myTop2, myWidth, myHeight), !heroSelect2, "", "Hero2");
		if( but2 == true  Input.touchCount > 0  (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)  heroSelect2 == false  isDragging == false)
		{isDragging2 = true; isDragging = false;}
		
		//moves the hero image2
		if ( isDragging2 )
		{
		//print (Input.touchCount);
		touchPosition = Input.GetTouch(0).position;
		Debug.Log (touchPosition);
		myLeft2 = touchPosition.x - myWidth * 0.5;
		myTop2 = Screen.height - (touchPosition.y + myHeight * 0.5);
		}
//		if(heroSelect2 == true)isDragging2 = false;
}

I wonder if someone could help me

This business of marking threads as "URGENT"is getting old. It’s not urgent, if it were, you’d be over in the commercial section offering cash for a solution. I’ve just stopped even reading code of people who mark things as urgent. Actually, as summer drags on, my desire to help people has waned. When school being again, it will probably wax anew.

That doesn’t help at all… if you don’t want to help, you don’t need to comment this :slight_smile:

OK, I’ll help you. Would you like my PayPal?

I don’t have any… that’s why I’m posting a thread here…not in the commercial section… :frowning:

Help us to help you. If the code failed to compile (as you say above), you were given some specific errors. Don’t make people guess what those errors are - post them.

@Jgodfrey: Okay… It only says Insert a semicolon at the end of this section.

if( but2 == true  Input.touchCount > 0  (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)  heroSelect2 == false  isDragging == false)

I don’t know what’s wrong… It’s the if statement…and it says I have to insert a semicolon…

Dont forget the ’ { ’

:wink:

Well, you obviously don’t need a semi-colon in the expression portion of an if block, so that’s not likely the offending code. Yeah, it’s a nasty looking expresssion, but (by eye) I don’t see a problem with it. What does the rest of the code look like that goes with that statement? I’d guess your problem is there…

I think there is a misreporting of the error. As JGodfrey stated, a semicolon does not close an in-statement.

I tried your code and I didn’t get any errors. The error’s elsewhere. It’s prolly a missing semi-colon, bracket or parenthesis from an earlier line.

@JRavey jgodfrey : that’s what I’m thinking too…But I check it more than three times and it keeps showing up that line on the console…

@all : In the end I reload all my older scripts and redone it with the same scripts and nothing goes wrong…thank you for helping me doing the scripts…

my conclusion : I don’t know what makes my code errors since I’ve never experienced this kind of bug before, next time I met this kind of bug I’ll make sure you all got the code.