Serialization of List<T> is not supported.

 1 public int v; // SUPPORTED
2 public GameObject go; // SUPPORTED
3 public Transform trans; // SUPPORTED
4 public int[] arrInt; // SUPPORTED
5 public Vector3 v; // SUPPORTED
6 [Serializable]
7 public struct HandsomeGuyInfo {
8 public int jjLength;
9 public Vector3 jjDirection;
10 public string[] girlFriendNames;
11 };
12 public HandsomeGuyInfo[] infos; // SUPPORTED
13 public List<int> lst; // NOT SUPPORTED, Use int[] instead

About menu: Assets | 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 }

InvokeRepeating is supported

Coroutine is supported.

read JSBinding + SharpKit / Supporting Coroutine for more information.

DON'T 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

Array is now treated as 'input' (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 //

Only 1 demension array is supported (JS <-> CS).

int[] arr; // OK
int[,] arr; // NO

Debug.Log(): Explicitly call ToString() for string parameter.

Vector3 v = Vector3.one;
Debug.Log("v is " + v); // NO
Debug.Log("v is " + v.ToString()); // GOOD!

Generic Type including another Generic Type is not supported.

For example,

Dictionary<string, List<int>> dict; // NOT SUPPORTED
// But you can use this:
Dictionary<string, object> dict; // OK

DON'T use Reflection!

There is no type information in JavaScript, most functions of reflection are not available in JavaScript.

Unsafe code is not supported!

For example, char*, SharpKit doesn't support it.

Better not operate binary data in JavaScript.

For example, int[], byte[]. Operating binary data in JavaScript will have very very low performance, and get many bugs!

As an alternative, you can wrap these operations in C#, and expose interfaces to JavaScript.

Limited supported to 'SendMessage'

Member functions of JSComponent (and his derived classes) are fixed. You can not add member functions to JSComponent after game release. So if you want JSComponent to receive some message,  for example, OnEnemyAttacked, you'll have to add OnEnemyAttacked to JSComponent beforehand.

BTW, JSComponent and his derived classes support ALL predefined methods, for a full list, see Messages section in http://docs.unity3d.com/ScriptReference/MonoBehaviour.html

Add as many as possible classes to JSBindingSettings.classes array

If you want to delta-update scripts after game release, you better add as many as possible classes to JSBindingSettings.classes array.

Because you can use classes in that array after game release!

back to

JSBinding + SharpKit / Home

最新文章

  1. Android性能优化之内存优化练习
  2. Zookeeper-Zookeeper leader选举
  3. map的使用
  4. 【iCore3 双核心板_FPGA】例程十:锁相环实验——锁相环使用
  5. 关于在linux下清屏的几种技巧
  6. 《Linux系统 date、cal、hwclock时间命令的用法》
  7. Windows7 sp1 64位下安装配置eclipse+jdk+CDT+minGW
  8. Letter of inquiry about employment possibilities, e-mail version
  9. The Native POSIX Thread Library for Linux - 设计文档
  10. [刷题]算法竞赛入门经典(第2版) 4-10/UVa815 - Flooded!
  11. MySQL server has gone away错误的解决办法
  12. Node.js学习记录(一)--安装设置篇
  13. jenkins自动部署应用到tomcat中,编译后shell脚本的简单示例
  14. 001_深度剖析什么是 SLI、SLO和SLA?
  15. sitemap index
  16. LeetCode题解之Rotate String
  17. Android 开发工具类 30_sendXML
  18. 云备份厂商Rubrik再获2.61亿美元融资,估值高达33亿美元 转自中国存储网
  19. ajax post data 获取不到数据
  20. How to alter department in PMS system

热门文章

  1. 《day17_String_StringBuffer》
  2. (转)经典收藏 50个jQuery Mobile开发技巧集萃
  3. ISO c++11 does not allow conversion from string literal to &#39;char*&#39;
  4. windows程序设计笔记
  5. IO 流 定义
  6. HDU4055 - number string(DP)
  7. 解决:子元素设置margin-top,父元素也受影响的问题
  8. 结构体用于map,set时要重载运算符&lt;
  9. 101+ Manual and Automation Software Testing Interview Questions and Answers
  10. Python MySQL ORM QuickORM hacking