3 ms·
Don't use javascript. Seriously. Use C#.
by socialist_coder 12y ago
Don't use javascript. Seriously. Use C#.
- DonHopkins 12y agoI agree, C# is a much better programming language than JavaScript. Well worth the time to learn, even if you already know JavaScript. The version of JavaScript that Unity has is actually just a thin veneer around the Mono runtime, so it's not quite the same language or environment you use in the browser or node.js. However, there are some good reasons for using JavaScript in Unity: using existing libraries and developing new libraries that run in browsers, mobile devices, node.js, Unity3D and other JavaScript VMs, so you can have one code base that runs across all those platforms. There some problems and impedance mis-matches to solve, to make running existing JavaScript code in Unity3D more seamlessly possible and even convenient. And that's exactly what Browserify does for web browsers! http://browserify.org/ http://browserify.org/ There is a great tool called Browserify that solves the problem of running npm modules written for node.js in the browser, resolving dependencies, inserting shims to implement standard asynchonous node.js APIs in terms of the existing Unity3D apis, and packaging everything together in one file that can be downloaded and run in a web browser. Browserify for Unity3D could be called Unityify. For example of how it would be useful, I'm rewriting Micropolis (based on the original SimCity Classic code from Maxis) in JavaScript, and I'd like to be able to easily drop the JavaScript simulator engine code into Unity3D, and implement a nice 3D or 2D user interface in C# or whatever useful modules I can find on the Unity Asset Store. I think "Unityify" would be a useful tool that lots of people could use, since the argument for running the same JavaScript code in both web browsers and node.js servers and desktop apps also extends to running it in Unity3D. Ideally it would be able to just pass the JavaScript libraries through with minimal wrappers, when building Unity3D projects for deployment in browsers with WebGL. Is anyone else interested in such a tool, or even working on it already, or interested in collaborating?
- doyoulikeworms 12y agoHuh, that's a good idea! I wonder if it would be possible to integrate a Mono-compiled version of Javascript (e.g., IronJavascript) into Unity? Some cursory Googling produced these interesting posts on integrating IronScheme[0] and IronPython[1] with Unity. [0]: http://forum.unity3d.com/threads/76266-Facilities-for-script-languages-Scheme-in-particular http://forum.unity3d.com/threads/76266-Facilities-for-script... [1]: http://techartsurvival.blogspot.com/2013/12/embedding-ironpython-in-unity-tech-art.html http://techartsurvival.blogspot.com/2013/12/embedding-ironpy...