Serialization of List<T> is not supported.

  1. 1 public int v; // SUPPORTED
  2. 2 public GameObject go; // SUPPORTED
  3. 3 public Transform trans; // SUPPORTED
  4. 4 public int[] arrInt; // SUPPORTED
  5. 5 public Vector3 v; // SUPPORTED
  6. 6 [Serializable]
  7. 7 public struct HandsomeGuyInfo {
  8. 8 public int jjLength;
  9. 9 public Vector3 jjDirection;
  10. 10 public string[] girlFriendNames;
  11. 11 };
  12. 12 public HandsomeGuyInfo[] infos; // SUPPORTED
  13. 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. 1 using UnityEngine;
  2. 2 using System.Collections;
  3. 3
  4. 4 using SharpKit.JavaScript;
  5. 5
  6. 6 [JsType(JsMode.Clr,"../../StreamingAssets/JavaScript/SharpKitGenerated/2DPlatformer/Scripts/Gun.javascript")]
  7. 7 public class Gun : MonoBehaviour
  8. 8 {
  9. 9 public GameObject rocketGO; // Prefab of the rocket.
  10. 10 public float speed = 20f; // The speed the rocket will fire at.
  11. 11
  12. 12 //........
  13. 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. 1 UnityEngine.Object obj = ...;
  2. 2
  3. 3 GameObject go = obj as GameObject; // DON'T do this
  4. 4 GameObject go = (GameObject)obj; // GREAT

Array is now treated as 'input' (readonly) when calling C# function from JavaScript.

  1. 1 // C#
  2. 2 void ModifyArray(int[] arr)
  3. 3 {
  4. 4 for (var i = 0; i < arr.Length; i++)
  5. 5 arr[i] = i;
  6. 6 }
  7. 7
  8. 8 // JS
  9. 9 var arr = [5,2,3,2];
  10. 10 ModifyArray(arr); // call C# function
  11. 11
  12. 12 //
  13. 13 // arr is still [5,2,3,2] !!
  14. 14 //

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

  1. int[] arr; // OK
  2. int[,] arr; // NO

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

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

Generic Type including another Generic Type is not supported.

For example,

  1. Dictionary<string, List<int>> dict; // NOT SUPPORTED
  2. // But you can use this:
  3. 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

JSBinding + SharpKit / Important Notes的更多相关文章

  1. JSBinding+SharpKit / 菜单介绍

  2. JSBinding + SharpKit / 编译 Cs 成 Js

    轻轻一点菜单:[JSB | Compile Cs to Js] 主要产出:StreamingAssets/JavaScript/SharpkitGeneratedFiles.javascript,你的 ...

  3. JSBinding+SharpKit / 更新的原理

    首先,其实不是热更新,而是更新. 热更新意思是不重启游戏,但只要你脚本里有存储数据,就不可能.所以只能叫更新. 但大家都这么说,所以... 先举个具体的例子: 如果是C#:在 Prefab 的 Gam ...

  4. JSBinding+SharpKit / JavaScript调试

    注意: 1 Firefox 的版本用41 2 我发现调试很难用的,现在我都用打印 步骤参考图:

  5. JSBinding + SharpKit / 实战:转换 Survival Shooter

    从 asset store 下载 Survival Shooter (商店里有2个版本,一种是给Unity5用的,一个是给Unity4.6用的,我们这个实验用的是后者,版本是2.2.如果) 1 删除多 ...

  6. JSBinding + SharpKit / JavaScript 加载流程

    首先,现在的方案是游戏启动就加载全部的 JavaScript 代码. 先看下 StreamingAssets/JavaScript/ 文件夹下的目录结构:

  7. JSBinding + SharpKit / 常见问题

    运行时出现: Return a "System.Xml.XmlIteratorNodeList" to JS failed. Did you forget to export th ...

  8. JSBinding + SharpKit / Coroutine支持

    首先得深入了解协程的原理.如果还没有完全理解,建议看这篇: http://wiki.unity3d.com/index.php/CoroutineScheduler 另外还要对 JavaScript ...

  9. JSBinding + SharpKit / 原理篇:内存管理与垃圾回收

    C# 和 JS 都有垃圾回收机制,需要保证 2 者能够分工协作. 类对象 类在C#中是引用类型.我们在 C# 中维护了2个map,保存 C# 对象和 JS 对象的一一对应关系. 举一个例子,看以下代码 ...

随机推荐

  1. iOS对象序列化

    系统对象的归档我就不介绍了,这个不复杂,自己看一下就会了. 我在这里主要介绍自定义对象的归档. Sample.h文件 // //  Sample.h //  Serialization // //   ...

  2. 解密SQL SERVER 2005加密存储过程,函数

    在SQL SERVER 2005中必须用专用管理连接才可以查看过程过程中用到的表 EG:sqlcmd -A 1>use test 2>go 1>sp_decrypt 'p_testa ...

  3. (转)SQLLite数据操作

    原文:http://dreamboy.blog.51cto.com/3180937/722352 SQLLite数据操作 一般数据采用的固定的静态数据类型,而SQLite采用的是动态数据类型,会根据存 ...

  4. Ubuntu系统启用Apache Mod_rewrite模块

    在终端中执行 sudo a2enmod rewrite 指令后,即启用了 Mod_rewrite 模块. 另外,也可以通过将 /etc/apache2/mods-available/rewrite.l ...

  5. PHP文件系统处理(二)

    1.文件的打开和关闭(读文件中的内容,向文件中写内容)            读取文件中的内容                file_get_contents()     //php5以上 < ...

  6. 通过 itms-services 协议,发布或者分享 iOS 应用程序

    导读:itms-services 协议常用于 iOS 企业应用的无线部署,这可在不使用 iTunes 的情况下将内部软件发布或者分享给用户. 一.前期准备资料: 1.应用程序 (.ipa) 文件(使用 ...

  7. Android重写getResources规避用户调整系统字体大小影响Android屏幕适配

    Android屏幕适配一直是一个头疼的问题.除此之外还要考虑APP在实际应用场景中,用户千奇百怪的设置,最常见的用户设置行为就是设置手机的字体大小,比如把字体设置成超大或者超小,这对屏幕适配又带来额外 ...

  8. GridView 分页方法

    要实现GrdView分页的功能. 操作如下: 1.更改GrdView控件的AllowPaging属性为true. 2.更改GrdView控件的PageSize属性为 任意数值(默认为10) 3.更改G ...

  9. Unity3D ShaderLab 布料着色器

    Unity3D ShaderLab布料着色器 布料着色器是我们在虚拟现实中经常使用的着色器.本篇就来完成一个较为简单的布料着色器. 新建Shader,Material,InteractiveCloth ...

  10. .NET概念:.NET程序编译和运行

    .NET概念:.NET程序编译和运行 分类: c#程序设计 2012-02-29 15:46 3001人阅读 评论(2) 收藏 举报 .net编译器语言microsoftassemblyvb.net ...