- Home /
C# scripting and Javascript in the same project?
I am just beggining with unity and i am going to prototype a vehicular combat game. I have decided to use the tutorial on the unity website as the base code for the behaviourand control of the vehicle, these scripts are already provided with the tutorial in javascript.
However i am not very comfortable with javascript, not enough to be able to write all of my scripts in it, i am much more comfortable using C# and i have a 12 week time limit to achieve a working prototype so i don't have a lot of time to become comfortable with javascript.
My question is this: is it possibble to have scripts in 2 different languages, javascript and c# in the same game project? While i wouldn't change scripting languages within the same script file a game object may have scripot files using both languages, is this possible?
P.S. I am aware this is not the proper, clean or best way to achieve what i want but time is a factor, and the focus is on getting a working prototype even if it is "quick and dirty". I would work on converting the code to one language at a later date when i have time.
Thank you in advance.
Answer by · Aug 16, 2010 at 04:57 AM
You can use scripts from both languages in the same project. I've seen Eric5h5 suggest that you read the script compilation reference page when mixing languages.
Answer by MarkrosoftGames · Jan 28, 2014 at 05:59 AM
from this link http://docs.unity3d.com/412/Documentation/Manual/Scripting.html
Accessing a variable defined in C# from Javascript To access variables defined in C# scripts the compiled Assembly containing the C# code must exist when the Javascript code is compiled. Unity performs the compilation in different stages as described in the Script Compilation section in the Scripting Reference. If you want to create a Javascript that uses classes or variables from a C# script just place the C# script in the "Standard Assets", "Pro Standard Assets" or "Plugins" folder and the Javascript outside of these folders. The code inside the "Standard Assets", "Pro Standard Assets" or "Plugins" is compiled first and the code outside is compiled in a later step making the Types defined in the compilation step (your C# script) available to later compilation steps (your Javascript script).
In general the code inside the "Standard Assets", "Pro Standard Assets" or "Plugins" folders, regardless of the language (C#, Javascript or Boo), will be compiled first and available to scripts in subsequent compilation steps.
Answer by zannghast · Sep 08, 2010 at 07:34 AM
What Marowi said was true. As an added fact (which you'll also find in the link Marowi provided), you should be wary of how your scripts access different objects defined in scripts of other languages.
If you haven't already, I suggest you read the page in the link, everything's right there.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071314im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Convert .js to C# 2 Answers
Cant get C# to talk to JavaScript 3 Answers
Script translation 2 Answers
I have my items in inventory, now if I could only use them... 1 Answer
How is the relationship between Rodrigo Barreto de Oliveira and Unity? 1 Answer