首页 > Web开发 > 详细

JSBinding + SharpKit / Important Notes

时间:2015-06-21 00:37:41      阅读:227      评论:0      收藏:0      [点我收藏+]

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

JSBinding + SharpKit / Important Notes

原文:http://www.cnblogs.com/answerwinner/p/4591248.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!