JSBinding / Gen Bindings

时间:2023-03-09 02:59:27
JSBinding / Gen 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, and maintain this array.

 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 }

Add to JSBindingSetting.enums to export enums:

public static Type[] enums = new Type[]
{
typeof(KeyCode), // add here
};

Click this menu to export those classes:

Assets | JavaScript | Gen Bindings

JSBinding / Gen Bindings

NOTE: This menu must be executed when swiching to a different platform in Build Settings dialog!

after finished, two parts of code will be generated:

1) C# files in folder Assets/JSBinding/Generated/

JSBinding / Gen Bindings

2) JavaScript files in folder StreamingAssets/JavaScript/Lib/Gen.javascript (all in one)

JSBinding / Gen Bindings

back to JSBinding / Home