- Home /
JavaScript Version of foreach (Touch touch in Input.touches)
Hey guys, I've been having some trouble with touch buttons, I can get them to work fine for C#, but I have a script that I've only been able to figure out in JavaScript and I need to touch a button to run it, I tried using my usual touch script and a bunch of other different methods after researching this for hours but I can't find a JavaScript version.
So what I'm trying to do is turn the code bellow into a JavaScript friendly code:
#pragma strict
import System.IO;
import System;
public var moveThisButton : GUITexture;
function Update()
{
foreach (Touch touch in Input.touches)
{
if (moveThisButton.HitTest (touch.position))
{
//Do The JavaScript Stuff
}
}
}
I think my public var GUITexture is right, but I'm not sure, so if it's wrong too, please feel free to correct that too.
Thanks all!
Answer by Andres-Fernandez · Jun 02, 2014 at 10:31 AM
Ahh, awesome, no I hadn't, I'd tried var and a few other variations of touch such as touch count[0] etc.
Thanks a lot, I didn't realize it was just 'for' and not 'foreach'
And I couldn't find a doc on it, I'd looked but didn't come across it.
Thanks again Andres!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can this be made into javascript 1 Answer
Distribute terrain in zones 3 Answers
iTween Visual Editor Event Call from C# to Javascript 1 Answer
How do you climb a ladder 1 Answer