- Home /
Migrating data from C# to UnityScript
I'm working on a multitouch project with uniTUIO, unfortunately I wrote the majority of my game in UnityScript. That is a problem because the touch inputs that uniTUIO correctly recognizes only exists in the C# part.
So I'm searching for a way to catch the touches uniTUIO collects from the C# scripts, so that I can use them in my already existing UnityScript scripts.
Answer by ehnaton · Jun 07, 2012 at 10:48 AM
I've got such a problem. I use an empty gameobject and it's transform parametres to convert data from sharp to java. For your problem you can store toche's info and create with every new touch new object with specific names.
That's exactly what I had in $$anonymous$$d. I'm creating a fake touch indicator from the cursor prefab and storing the touch relevant infos inside a unityscript on it.
Answer by Berenger · Jun 06, 2012 at 06:30 PM
Could you elaborate this? What should I put into the Standard Assets folder, the uniTUIO C# scripts or my UnityScript scripts?
Edit: I could use Send$$anonymous$$essage for every touch the C# script gets and write a unityScript method that fills them into a touch array inside the unityScript script. No, doesn't work :-/
The uniTUIO scripts should go in the "Plugins" folder (same effect as "Standard Assets", but more aptly named), so they are compiled first. Haven't tried it (since we don't use JS and also use the older "uniTUIO CE RC1" edition), but the only script you'd need to convert to JS is the BBSimpleTouchableObject, so you can extend this to overload its "handleSingleTouch" etc. You'll probably have to move the .js version of it out of the Plugins folder, or you'll run into the same compilation order problem.
@Wolfram that could work, but my problem is that iPhoneInput.touches is only filled inside the BBSimpleTouchableObject.cs, if I try to access it from the outside it is empty.
Hm, sorry, I'm not familiar with the current edition of uniTUIO (I just realized we're using the uniTUIO version before "uniTUIO CE RC1"). IIRC, the current version creates (="fills") iPhoneTouch events in BBIPhoneTouch$$anonymous$$anager.cs. You can either use them directly (as 2D touches), or use BBSimpleTouchableObject which raycasts them into the scene and calls handleSingleTouch etc. if an object is hit. Don't forget to put the touch manager prefab into your scene.
If that still doesn't help you, maybe you should ask your question in the uniTUIO forum: http://www.xtuio.com/index.php/developerblog/support-forums/5-unituio-forum
I think I got an idea, I'll remodel the crosshair prefab into an touch indicator. That way I can easily get all information I need, the fingerID (the unique ID of the crosshair) and it's position.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Saving final score and displaying on main menu 1 Answer
null texture passed to GUI.DrawTexture 0 Answers