JSBinding / Code Snippets
new a gameobject & overloaded methds
var go1 = new UnityEngine.GameObject.ctor();
var go2 = new UnityEngine.GameObject.ctor$$String("Hello");
add/get c# component
var trans = go.GddComponent$1(UnityEngine.Transform.ctor);
var image = go.AddComponent$1(UnityEngine.UI.Image.ctor);
image.set_color(new UnityEngine.Color.ctor$$Single$$Single$$Single(125/255, 78/255, 3/255));
add/get javascript component
// a javascript monobehaviour
jss.define_mb("Dog", function () {
this.Eat = function () {
print("EAT!");
}
}); // some function
function fun(goDog) {
goDog.AddComponent$1(jss.Dog);
var dog = goDog.GetComponent$1(jss.Dog);
dog.Eat();
}
define a javascript monobehaviour
jss.define_mb("UIController", function () {
// UnityEngine.Object
// add this variable to Unity Inspector and drag something to it
this.oTileRoot = null;
this.oScore = null;
this.oBestScore = null;
// auto called from c#
this.Start = function () {
}
// auto called from c#
this.Update = function () {
}
});

static methods & enum
if (UnityEngine.Input.GetKeyDown$$KeyCode(UnityEngine.KeyCode.UpArrow)) {
inputMgr.emit("move", 0);
break;
}
properties (get_, set_)
var e = this.animator.get_enabled();
this.animator.set_enabled(!e);
var pos = this.trans.get_position();
other.trans.set_position(pos);
ref/out
var $cv = { Value: UnityEngine.Vector3.get_zero() };
var newPos = UnityEngine.Vector3.SmoothDamp$$Vector3$$Vector3$$Vector3$$Single(
this.trans.get_position(),
this.toPos,
$cv,
0.07);
print("new pos: " + $cv.Value);
delegates & properties & overloaded functions
btn.get_onClick().RemoveAllListeners();
btn.get_onClick().AddListener$$UnityAction(function () {
print("button clicked!");
});
Coroutine
jss.define_mb("CorutineTest", function() {
// called from c#
this.Start = function () {
this.StartCoroutine$$IEnumerator(this.SayHello());
}
// notice syntax here!
this.SayHello = function*() {
var i = 10;
while (i > 0) {
print("hello jsb " + i);
i--;
yield new UE.WaitForSeconds.ctor(1);
}
}
this.Update = function () {
var elapsed = UE.Time.get_deltaTime();
// update coroutines and invokes manually!
this.$UpdateAllCoroutines(elapsed);
this.$UpdateAllInvokes(elapsed);
}
}
back to JSBinding / Home
JSBinding / Code Snippets的更多相关文章
- Code Snippets 代码片段
Code Snippets 代码片段 1.Title : 代码片段的标题 2.Summary : 代码片段的描述文字 3.Platform : 可以使用代码片段的平台,有IOS/OS X/ ...
- Xcode开发中 Code Snippets Library 的相关用法
当在进行项目的时候,总会遇到很多相同的写法.因此,我们可以使用Code Snippets Library 来进行代码小片段的“封装”: 以Xcode中常用的属性为例: 使用步骤如下: 1.在Xcode ...
- Xcode开发技巧之Code Snippets Library
http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...
- Problem and Solution Code Snippets
(积累知识,遇到发展,本文仅用于备忘录,不时它需要召回准备) Problem: 依据String的大小来调整Label的frame.在view中又一次更新views的layout并显示. Soluti ...
- Sublime Text3—Code Snippets(自定义代码片段)
摘要 程序员总是会不断的重复写一些简单的代码片段,为了提高编码效率,我们可以把经常用到的代码保存起来再调用. 平时用sublime安装各种插件,使用Tab键快速补全,便是snippets(可译为代码片 ...
- iOS开发-代码片段(Code Snippets)提高开发效率
简介 在 XCode4 引入了一个新特性,那就是“代码片段(Code Snippets)”.对于一些经常用到的代码,抽象成模板放到 Code Snippets 中,使用的时候就只需要键入快捷键就可以了 ...
- vscode & code snippets
code snippets vscode & code snippets https://github.com/xgqfrms/FEIQA/tree/master/000-xyz/templa ...
- Useful code snippets with C++ boost
Useful code snippets with C++ boost Is Punctuation It’s very straight forward to use boost.regex as ...
- Random Javascript code snippets
MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...
随机推荐
- nginx+tomcat 配置负载均衡
nginx 从Nginx官网下载页面(http://nginx.org/en/download.html)下载Nginx最新版本(我用的是nginx-1.8.1版本) 安装就直接把压缩包解压到一个路径 ...
- Design pattern---观察者模式
观察者模式:发布/订阅模式,当某对象(被观察者)状态发生改变时所有订阅该对象的观察者对象(观察者)都将更新自己 成员(4种): 1.抽象被观察者:将所有的观察者对象的引用存入一个集合,并且定义了添加 ...
- mac 文本编辑器 文本编码Unicode utf-8 不适用的问题
在mac上使用默认的文本编辑器打开下载的xx.txt文件,如果文本是gbk的编码可能会出现 文本编码Unicode utf-8 不适用的打开错误,如下图 解决方式: 文本编辑---偏好设置-----打 ...
- 使用CSS3 BACKFACE-VISIBILITY属性制作翻转动画效果
摘要: 通过backface-visibility:hidden;属性,我们可以使一个元素在翻转之后消失,这是可以使用另一个元素放在它的背面,从而制作出一种元素翻转之后出现另一个元素的效果. ... ...
- python—基础类的那点儿所以然
老师说:‘要知其然,更要知其所以然’~~~那么今天就来说点儿所以然,对python中的int,str,lst,dict和tuple等基础类中的方法做一些解析 那么类是什么呢? 官方的解释是这样的:对象 ...
- HTML问题,a href =" "和 a href ="#"这两个有什么区别?
a href ="" 默认打开的还是当前页面,会刷新一下重新打开.a href ="#" 浏览器地址栏网址后面会多显示1个#.不会刷新页面,会回到页面顶部.
- jQuery 获取checkbox 获取值
//全选 $("[name='checkbox']").attr("checked",'true'); //取消全选 $("[name='checkb ...
- i++问题
例题,以下代码的输出结果是什么? #include <stdio.h> int main() { ,,,,}; int *ptr = arr; *(ptr++) += ; printf(& ...
- java日期操作大全
摘自(http://www.blogjava.net/i369/articles/83483.html) java日期操作 大全 先来一个: 取得指定月份的第一天与取得指定月份的最后一天 http ...
- 树(一)——线段树
问题 现在有1~30这30个数,数N被抽上的概率正比于1/sqrt(N+1),求满足这个概率分布的随机数发生器. 思路 第一,如何解决这个"概率正比"问题. 第二,如何产生满足条件 ...