JSBinding + SharpKit / Generate JS Bindings

Classes in JSBindingSettings.classes array will be exported to JavaScript.

There are already many classes (most of them are from UnityEngine.dll) in that array, you have to add your own classes.

 1     public static Type[] classes = new Type[]
 2     {
 3         /*
 4          * Classes to export for demo
 5          * Add classes here to export
 6          */
 7
 8         typeof(UnityEngine.WheelCollider),
 9         typeof(UnityEngine.PhysicMaterial),
10         typeof(UnityEngine.Collision),
11         typeof(UnityEngine.ControllerColliderHit),
12         typeof(UnityEngine.CharacterController),
13
14         //....
15     }

Click this menu to export those classes:

after finished, two parts of code will be generated:

1) C# files in folder Assets/JSBinding/Generated/ (defined by JSBindingSettings.csGeneratedDir variable)

2) JavaScript files in folder StreamingAssets/JavaScript/Generated/ (defined by JSBindingSettings.jsGeneratedDir variable)

Also, StreamingAssets/JavaScript/GeneratedFiles.javascript file is generated, containing the file name list.

时间: 2024-10-12 13:45:38

JSBinding + SharpKit / Generate JS Bindings的相关文章

JSBinding+SharpKit / 生成JS绑定

将 UnityEngine 的代码导出到 JS.就可以在 JS 中使用 Unity 的功能. 当你下载完 JSBinding 代码后 此文件已经正确配置好了.不需要再进行配置  只需要执行一下菜单即可. 首先需要配置 JSBindingSetting.cs 中的 classes 数组 这个数组代码了要导出的 C#  的类 在项目中  可以直接把 UnityEngine.dll 的所有类全部写进去  一次性全部导出 以后就不需要再逐个添加了 (这边是举例子 只添加一小部分类) // // JSBi

JSBinding + SharpKit / Home

Description JSBinding is a great tool enabling you to run actual JavaScript in Unity3D. It contains Mozilla SpiderMonkey JavaScript engine version 33 library. New version is expected to work with SharpKit (sharpkit.net). SharpKit is an open source to

JSBinding + SharpKit / 编译 Cs 成 Js

轻轻一点菜单:[JSB | Compile Cs to Js] 主要产出:StreamingAssets/JavaScript/SharpkitGeneratedFiles.javascript,你的所有逻辑代码都在这里 其他产出: Temp/AllInvocations.txt:记录所有逻辑代码对框架代码的调用 (1) Temp/AllInvocationsWithLocation.txt:同上,但同时记录每个调用的文件名和行号 (2) Temp/YieldReturnTypes.txt:记录

JSBinding+SharpKit / 菜单介绍

[JSB | Generate JS and CS Bindings] 生成绑定,即让 Js 和 Cs 互通.详情请看 JSBinding+SharpKit / 生成 JavaScript 绑定 [JSB | Add SharpKit JsType Attribute for all Structs and Classes] 在所有逻辑代码中,所有类的定义前面加上 [JsType(JsMode.Clr, "~/Assets/StreamingAssets/JavaScript/SharpKitG

JSBinding + SharpKit / Convert 2DPlatformer to JavaScript version

2DPlatformer is a Unity3D official demo. Asset store URL: https://www.assetstore.unity3d.com/en/#!/content/11228 What we are going to do now is convert 2DPlatformer to JavaScript version. All C# scripts are all in 2DPlatformer/Scripts/ folder. We are

JSBinding + SharpKit / 实战:转换 2DPlatformer

2DPlatformer 是 Unity3D 的一个官方 Demo.本文将介绍使用 JSBinging + SharpKit 转换 2DPlatformer 的过程. 本文并不详细介绍每个步骤的细节.因为他们将在其他文章里做详细介绍. 准备工作:首先准备好 JSBinding 的工程,正确导入 JSBinding 插件. 2DPlatformer 是Unity3D的第一个示例代码,一共不到10M.麻雀虽小,五脏俱全.牵扯到很多东西,比如 prefab 的使用,结构体序列化,场景切换,音乐等等.

JSBinding + SharpKit / 常见问题

运行时出现: 1 Return a "System.Xml.XmlIteratorNodeList" to JS failed. Did you forget to export that class? 答:将这个类加入到 JSBindingSettings.classes 数组后运行一下菜单 JSB | Generate JS and CS Bindings. 特殊情况1:如果这个类并不存在,或者是被 DLL 隐藏了,导致无法添加,那么请添加他的基类.比如上面的 System.Xml

JSBinding + SharpKit / run samples

Import JSBinding package to your project. on Windows 1) for 32bit editor: copy Assets/Plugins/x86/mozjs-33.dll to UnityInstallDir/Editor folder 2) for 64bit editor: copy Assets/Plugins/x86_64/mozjs-33.dll to UnityInstallDir/Editor folder open scene J

JSBinding + SharpKit / Important Notes

Serialization of List<T> is not supported. public List<int> lst; // NOT supported, use int[] instead About menu: JSB | Add SharpKit JsType Attribute for all Structs and Classes. If you execute this menu more than once, only one JsType will be