Jump to content

Recommended Posts

Posted

I'm a newbie, so I figured I might ask :)

Has anyone ever used a leap motion sensor (link) with Unity?

If so, the modules for that hardware for Unity are written in C#, but with my group we wanted to code in Javascript. I haven't found infos about how to use different languages in the same game, is that possible and if so is it hard?

I know games are usually designed like that with different languages for optimization purposes, but is it possible with Unity? 

Thanks in advance for your expertise!

Posted (edited)

@clankill3r

The library for Unity is in C#, a language I don't know,  I don't know Javascript either, so I'll have to learn either one of them.

(I basically only know well Python)

And I heard JS is easier than C# but doing the game with the leap in JS would mean either doing it without Unity, and end up with something really simplified ( got only 3 months to do the project after study hours ), or trying to do it in Unity, mixing scripts in C# (leap motion scripts ) and JS (my scripts), or doing it all in C# in Unity.

I'm just afraid not to have enough time to learn C# because it looks frightening, what would you recommend?

Edited by laminutederire
Posted (edited)

About mixing JS and C#, my understanding is that it is possible but a bit messy because you have to understand script compilation order

All scripts that are compiled in this step have access to all scripts in the first group ("Standard Assets", "Pro Standard Assets" or "Plugins"). This allows you to let different scripting languages interoperate. For example, if you want to create a Javascript that uses a C# script: place the C# script in the "Standard Assets" folder and the Javascript outside of the "Standard Assets" folder. The Javascript can now reference the C# script directly.

See here: http://docs.unity3d.com/412/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html

 

EDIT: Maybe this one is clearer:

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.

http://docs.unity3d.com/412/Documentation/Manual/Scripting.html

Good luck, unity is nice but can be a bit weird sometimes to get to think within its boundaries and work around its limitations 

Edited by Corwin
Posted

About mixing JS and C#, my understanding is that it is possible but a bit messy because you have to understand script compilation order

See here: http://docs.unity3d.com/412/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html

 

EDIT: Maybe this one is clearer:

http://docs.unity3d.com/412/Documentation/Manual/Scripting.html

Good luck, unity is nice but can be a bit weird sometimes to get to think within its boundaries and work around its limitations 

merci beaucoup :)

i wasn't sure I understood it right :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...