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 added. this is good.
1 using UnityEngine; 2 using System.Collections; 3 4 using SharpKit.JavaScript; 5 6 [JsType(JsMode.Clr,"../../StreamingAssets/JavaScript/SharpKitGenerated/2DPlatformer/Scripts/Gun.javascript")] 7 public class Gun : MonoBehaviour 8 { 9 public GameObject rocketGO; // Prefab of the rocket. 10 public float speed = 20f; // The speed the rocket will fire at. 11 12 //........ 13 }
Coroutine is not supported.
you have to re-write yield code before compilint C# script to JavaScript. NOTE. JavaScript itself does support yield instruction, but can not work seamless with SharpKit.
Better not use ‘as‘ operator.
Check the JavaScript generated, you will know why. It will cause additional cost.
1 UnityEngine.Object obj = ...; 2 3 GameObject go = obj as GameObject; // DON‘T do this 4 GameObject go = (GameObject)obj; // GREAT
[] is now treated as ‘input‘, or ‘readonly‘ when calling C# function from JavaScript.
1 // C# 2 void ModifyArray(int[] arr) 3 { 4 for (var i = 0; i < arr.Length; i++) 5 arr[i] = i; 6 } 7 8 // JS 9 var arr = [5,2,3,2]; 10 ModifyArray(arr); // call C# function 11 12 // 13 // arr is still [5,2,3,2] !! 14 //
back to
JSBinding + SharpKit / Home
时间: 2024-10-12 21:10:14