- Home /
TouchPad in C#
Hello, How can i use this code in C#? var rotateTouchPad : Joystick;
Answer by Sajidfarooq · Aug 19, 2013 at 07:25 AM
public Joystick rotateTouchPad;
Really, there isn't any Joystick namespace in C#?
Unless you have a script called Joystick. It's not about C#, it's about your project in general (you'd get the same error with JS) Read http://docs.unity3d.com/Documentation/ScriptReference/Input.GetAxis.html
I simply converted your code from JavaScript to C#, as per the question.
Are you saying the original works in JavaScript, but not in C#?
I imported all the needed assets. Yes, works with JavaScript but not with C#.
Answer by DaveA · Aug 19, 2013 at 07:53 AM
Sajidfarooq has the correct C# syntax. You need to import the Standard Assets (Mobile) package.
If the problem was with import, he would see the same problem with JavaScript. Strange that the OP blames C# !
Yeah. OTOH sometimes these errors don't pop up until running. I think if you don't use types all the time, it might do that. Like
var joystick;
would not resolve to Joystick until set at runtime. But using the type
var joystick : Joystick;
should warn right away
Remember the OP was using strict-typing (var rotateTouchPad : Joystick). I'm guessing it did "warn", but newbies tend to ignore everything except for a downright error, something that wont let them proceed until fixed.
Answer by MehmetOguzDerin · Aug 19, 2013 at 09:28 AM
Hello, http://wiki.unity3d.com/index.php?title=Joystick This code isn't works. At least no touchpads on screen.
You should follow the Penelope tutorial in order to understand the joystick code.
Please do not post comments as answers. Read the FAQ in order to understand how you are supposed to ask questions here, how to answer, and what the voting process is. Your "karma" is still 1, which means every time you post, someone has to "approve" your post.
It works on JS but not on CS you don't get it? I know how to use. Just CS problem.
Lose the attitude.
You havent answered my previous comment on exactly what you mean by "works".
Have you tried publishing your code, and the JS version actually accepts the touch-pad input? Or are you running it in the simulator?
Hello, I'm working with Unity Remote 3 on iPhone. JS version was visible, but you know the var problem. CS solved the VAR problem but TouchPad's are invisible.
What var problem? Also, the Unity Remote converts touch to mouse-click, so you need to actually deploy to the device to properly test.