[RELEASED]Scripting with actual JavaScript!

Description

  • JSBinding is a tool enabling you to run actual javascript in Unity3D. It contains Mozilla SpiderMonkey JavaScript engine version 33 library.
  • JSBinding’s target users are people who would like to develop Unity applications with existing or writing javascripts or to use javascript to do anything else.
  • It’s very easy for javascript and c# to interact with each other. Unity’s script serialization, GameObject->Components relationship are specially supported.
  • Memory management is a tough stuff because javascript and c# both have garbage collection. JSBinding has overcame it. Users don’t need to do any work.
  • The package contains full source code! Feel free to customize you own needs!
  • Does JSBinding need Unity Pro? Unity 4 documents say using native dll is pro/mobile-only feature, but Unity 5 documents don’t.

See Online Documents for more information!
Asset store link The Best Assets for Game Making | Unity Asset Store
Download sample executable

Try to modify some javascript! Add this line somewhere you like:

print("hello, jsb!");
  • for Windows, javascript files are located at
  • for Mac OS, javascript files are located at

Features

  • Simply config c# types you need and with a single click, c# classes are available in javascript!
  • Full calling stack will be printed out whenever error occurs in JavaScript or C#.
  • Support Unity serialization: int(i), string(s), double(f), UnityEngine.Object(o), JavaScript MonoBehaviour(k)
  • Almost all c# methods are available in javascript:

struct/class
instance variables/methods
static variables/methods
properties
generic methods/parameters
ref/out
delegate
array
overloaded methods
indexers
operators
even COROUTINE

Supported Platforms

  • Windows Editor (32 and 64)
  • Windows Executable (32 and 64)
  • Mac OS X Editor (32 and 64)
  • Mac OS X Executable (32 and 64)
  • Android (armv7a)
  • iOS (32 and 64, works great with IL2CPP)

Email: answerwinner@gmail.com

Online Documents

Screen Shots


This is pretty cool. If you’re making an interactive website, and want to put Unity apps in it, you don’t have to have two different code bases.

Yeah, you are right. by exporting all classes you need in c#, all you have to deal with is actual JavaScript and Unity Editor. Let’s say bye-bye to c# :smile:.

Is it too cheap so people don’t believe it can provide good functions?
OR
no one is interested…
OR
should I make it free?

1 Like

You’re aiming at a very narrow group - someone who wants to make games with Unity, and would prefer vanilla Javascript to C# or boo. Which is probably not a lot of people.

I’m not sure how to break this to you, but here goes: Javascript is a horrible, horrible language. It’s very widespread because it works in the browser, but it’s still crazy bad at doing stuff that’s not strictly browser stuff. The tool is really, really cool, but it’s based on the assumption that developers would want to write Javascript - the ECMAscript version - over C#. That’s probably not that many people.

6 Likes

I agree with what Baste has said. Maybe years ago this would be more sought after, but most have already shifted away from the JavaScript paradigm in exchange for C#.

ok, i got it.
for now, may be it can be used to make tools, modify something during run-time, etc.

1 Like

This plugin has been updated to version 1.2.0. (Feb 18,2015)

Not bad, not a huge fan of javascript nor have I ever really used it much. Still believe C#, C++ or Java is superior, but if it works I guess some out there will find it use full… One thing that would impress me is if it actually works with other javascript libraries (node.js for instance?) and if it do how do you exactly communicate with the MONO.NET unity API? Having a hard time seeing how that would work?

@Jacksendary

If you are familiar with LUA Binding (cocos2d-x) or other JS Binding, this plugin does the same thing. Only one difference: This plugin works with C#, most of the ‘bindings’ works with C/C++.

  1. This plugin uses Mozilla SpiderMonkey JavaScript engine. It supports standard ECMAScript. (So it doesn’t support node.js because node.js is based on Google V8?)

Most of classes and functions are supported, some syntax are not supported, for example:
(JS->CS) Generic Functions, (e.g. gameObject.AddComponent();), but most of them have overloaded functions to use.(e.g. gameObject.AddComponent(“CharacterController”):wink:
(JS->CS) Functions with complex parameters, such as Dictionary<int, string>. Users almost don’t need it, and it is not high-efficient.

For parameters of basic types, (string, int, float, double), they are correctly converted.

It’s easy to use.
When you call C# functions from js, you write js code as if it the functions were implemented in js.

var go = new GameObject("i love you"); // js code, exactly the same with c#
Physics.Raycast(Input.mousePosition);

Some syntax are supported in js, but a little inconvenient:

// C#
Vector3 v = v1 + v2;
// JS
var v = Vector3.op_Addition(v1, v2);

Generally, you don’t have to care about the generator code, only take care of the generated code.


Edit (2016 July 13)
Text above is old comments.

I see, I’m not much into language design and such but sound pretty interesting, probably not the plugin for me tho, as I do think C# give better flexibility , would love to be able to use C++ with Unity3D (as natively supported language - not as a plugin or with DLLImport), but Good luck with it there sure must be some javascripts fans that can use this! :slight_smile:

back here again, some news. :).

I am still working on this plugin. It changes a lot now.
In next new version, it will enable you develop your game with C# as usual.
After you’ve finished your game, It can automatically convert C# to actual JavaScript with the help of SharpKit.net.

Why do we do this? Because it’s not possible to update Unity C# scripts when releasing new version. But it’s OK to update JavaScript files. Update them just like you update models, textures.

Will you be interested?


Edit (2016 July 13)
This package no longer uses SharpKit to compile c# to javascript. It just let you write javascript.

Wouldn’t that make your game exceptionally hackable? And stealable?

The question here is, what problems are you trying to solve?

@angrypenguin

You can encrypt you js files.

On iOS, each time you have new contents(scritps), users are required to re-download the whole game because it’s not possible to update scripts. But if scripts are translated to JS, they become normal assets and can be delta updated.

1 Like

Ok, but what problem does that solve? Why is not being able to delta update a bad thing?

Furthermore, is that in line with Apple’s TOS and the App Store rules?

1 Like

What, you expect actual market research before sinking time into developing an asset? I have no time for this. :slight_smile:

@angrypenguin

It’s not a bad thing, but if you have to update your game frequently, waiting for Apple to approve is a waste of time.

Apple does not clearly say that SpiderMonkey js engine is allowed (as far as I know), but the js-version of cocos2d-x (http://cocos2d-x.org/) already did this. If … i said if, this is plugin is declined by Apple, you are still able to use C# version.


Edit (2016 July 13)
This package no longer uses SharpKit to compile c# to javascript. It just let you write javascript.

I do know there are cases where this has been treated with… extreme lenience. However, none of those cases were people doing it specifically to avoid the app review guidelines for updates.

Edit: My point isn’t to shoot it down, in any case. I can imagine at least one case where this would come in handy, which is porting something that’s already written in JavaScript. Another could be making apps where the whole point is that the user can program things.

Most users of cocos2d-x would choose LUA or JS as main developing language. If Apple reject these engines, they have to totally rewrite the code.

This plugin is just an option. :slight_smile:

Version 1.5.0 has been released.
It is expected to work with SharpKit (sharpkit.net)


Edit (2016 July 13)
This package no longer uses SharpKit to compile c# to javascript. It just let you write javascript.