Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I like the simplicity of unityscript, at same time I also like the plenty of c# library and open source projects. I prefer to put my model/controller/logic flow in unityscript using standard unity3d sdk and invoke c# extension library. Is there any sample project demonstrate how to mix the two scripts in one project?

Your comment welcome

share|improve this question
    
What is unityscript? Do you mean Javascript? Or Boo? The Unity website only lists 3 scripting languages. unity3d.com/unity/workflow/scripting –  Katana314 Jun 18 '13 at 13:39
2  
@Katana314 Unity's JavaScript isn't really JavaScript (and has a lot of gotchas for people familiar with AS3 or browser scripting), so people have taken to calling it UnityScript. –  michael.bartnett Jun 18 '13 at 14:01
add comment

4 Answers

up vote 1 down vote accepted

If you want to use C# classes within UnityScript, you need to place the C# classes directly in the 'Standard Assets' folder.

Otherwise, due to the way that Unity compiles it's code, you cannot reference C# classes from UnityScript or vice versa. By placing them within the 'Standard Assets' folder, you ensure that those files are compiled first, and then the classes they generate will be available to the other script files at compile time.

share|improve this answer
    
Good point. Creating the scripts within the Unity editor (Add component->New script) is a nice way for this stuff to happen automatically. –  Byte56 Jun 18 '13 at 15:33
add comment

You can mix Javascript and C# scripts in one project with Unity. They cannot be compiled into the same file, but the same project is fine. I believe the base project that you start with in Unity3D contains both Javascript and C# if you want an example.

share|improve this answer
add comment

I agree with Byte56 and, just as an improvement at his answer, I recommend to check the official Car Tutorial: it's a project containing both Unityscript and C# scripts.

share|improve this answer
add comment

You can do it, it is done most of the time when it comes to projects that need to use servers. Your game client can run on C# and UnityScript, while the server runs on Java. As Byte said, you need to compile it in different project files. "No JavascriptContents.cs"

You can go to http://www.3dbuzz.com/ they have a ton of tutorials. You need to pay for it, but I haven't seen a place with more hours of tutorials in one place. You don't need to bother watching tutorials how to do this in particular. But the best shot would be not to mix it up too much. You might have problems while trying to access c# variable data with JavaScript(unity script). So don't do health with C#, movement and mana with Java, because this will generate problems, big ones.

http://answers.unity3d.com/questions/186244/how-do-i-access-a-variable-in-one-script-from-anot.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.