- Home /
Using JavaScript and C# inside one script
In the 4 months I'm using Unity, I've only used JavaScript.
I believe I'd read that one can use JavaScript AND C# in the same script, but I cannot remember where.
If this is correct, what script should this be? (In the editor do I select Scripts->CreateNew->JavaScript OR C Sharp Script?)
What I have at the moment, is a JS in which I want to use a List<>.
The first line of the script is:
using System.Collections.Generic;
Inside the script, there are JS lines and C# lines (I use C# to create and manipulate the List).
When I hit save, I get the error: ....(scriptName.js (1,6): UCE0001: ';' expected. Insert a semicolon at the end.
What did I do wrong?
You can still use the full $$anonymous$$ono/.NET library in Javascript
Answer by Jessy · Jan 18, 2011 at 08:56 PM
I believe I'd read that one can use JavaScript AND C# in the same script, but I cannot remember where.
No, you read that you can use them in the same project.
Answer by DaveA · Jan 18, 2011 at 08:55 PM
I've never heard of having both types of script in the same file, but you can have them in the same project, scene, object, as different files of course. I think it would be confusing a 'bad practice' to try to mix script languages in the same file, even if it could be done.