1
\$\begingroup\$

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

\$\endgroup\$
2
  • \$\begingroup\$ What is unityscript? Do you mean Javascript? Or Boo? The Unity website only lists 3 scripting languages. unity3d.com/unity/workflow/scripting \$\endgroup\$
    – Katana314
    Commented Jun 18, 2013 at 13:39
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ Commented Jun 18, 2013 at 14:01

4 Answers 4

2
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Good point. Creating the scripts within the Unity editor (Add component->New script) is a nice way for this stuff to happen automatically. \$\endgroup\$
    – House
    Commented Jun 18, 2013 at 15:33
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .