- Home /
Trying to convert this javascript code to C#
//This creates a variable which must be assigned to an object with a Controller attached. var myController : CharacterController;
//This variable must take a GameObject with a Transform Component - almost anything var myGenericObject : Transform;
//This variable looks for an object with an instance of a script attached - this one to be precise. var myTestObject : ComponentTest;
Answer by SisterKy · Aug 30, 2011 at 06:55 PM
Hm... I'm not good with c#, but I think this should work:
public CharacterController myController;
public Transform myGenericObject;
public ComponentTest myTestObject;
not sure if ComponentTest needs to be ComponentTest.cs or can be ComponentTest.js though... but if it's .js it needs to compile first.
Further reading:
http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html
http://answers.unity3d.com/questions/10856/cant-find-namespace-accessing-javascript-from-c-or.html
Your answer
Follow this Question
Related Questions
Converting a JS script into C# - hit a wall with arrays... 1 Answer
Call JavaScript from c# Help! 0 Answers
Multiple Cars not working 1 Answer
Some Basic Conversions from JavaScript to C# 1 Answer
Integer to Character in unityscript 2 Answers