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的更多相关文章

  1. Code Snippets 代码片段

    Code Snippets 代码片段       1.Title : 代码片段的标题 2.Summary : 代码片段的描述文字 3.Platform : 可以使用代码片段的平台,有IOS/OS X/ ...

  2. Xcode开发中 Code Snippets Library 的相关用法

    当在进行项目的时候,总会遇到很多相同的写法.因此,我们可以使用Code Snippets Library 来进行代码小片段的“封装”: 以Xcode中常用的属性为例: 使用步骤如下: 1.在Xcode ...

  3. Xcode开发技巧之Code Snippets Library

    http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...

  4. Problem and Solution Code Snippets

    (积累知识,遇到发展,本文仅用于备忘录,不时它需要召回准备) Problem: 依据String的大小来调整Label的frame.在view中又一次更新views的layout并显示. Soluti ...

  5. Sublime Text3—Code Snippets(自定义代码片段)

    摘要 程序员总是会不断的重复写一些简单的代码片段,为了提高编码效率,我们可以把经常用到的代码保存起来再调用. 平时用sublime安装各种插件,使用Tab键快速补全,便是snippets(可译为代码片 ...

  6. iOS开发-代码片段(Code Snippets)提高开发效率

    简介 在 XCode4 引入了一个新特性,那就是“代码片段(Code Snippets)”.对于一些经常用到的代码,抽象成模板放到 Code Snippets 中,使用的时候就只需要键入快捷键就可以了 ...

  7. vscode & code snippets

    code snippets vscode & code snippets https://github.com/xgqfrms/FEIQA/tree/master/000-xyz/templa ...

  8. Useful code snippets with C++ boost

    Useful code snippets with C++ boost Is Punctuation It’s very straight forward to use boost.regex as ...

  9. Random Javascript code snippets

    MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...

随机推荐

  1. PHP 小方法之 计算两个时间戳之间相差的日时分秒

    if(! function_exists ('timediff') ) { function timediff($begin_time,$end_time){ if($begin_time < ...

  2. j.一个NIO与SSLEngine结合的例子

    对于BIO通道的程序来讲,建立起SSLServerSocket之后,后续的工作就和普通的ServerSocket没有什么区别了,这是因为JDK中通过JSSE的API,封装了SSL通道的实现逻辑,否则, ...

  3. jquery动画基础

    根据id改变字体大小的动画 <div class="speech">样式切换</div> <div id="switcher"&g ...

  4. CSS权重及样式优先级问题

    CSS权重值计算 一条样式规则的整体权重值包含四个独立的部分:[A, B, C, D]; (1) A 表示内联样式(写在标签的style属性中),只有 1 或者 0 两个值:对于内联样式,由于没有选择 ...

  5. Js获取后台集合List的值并操作html

    功能:将后台传到前端JSP的List中的float型数值转换为百分比显示 HTML代码: <s:iterator value="colorConfigList" status ...

  6. 回顾CSS布局易混淆的概念

    一.浮动模型 元素默认是static的,不能浮动,但可以用CSS样式设置为浮动 浮动模型只有两个值 float:left 和 float:right ,可以让块状元素同行显示 二.层模型 top/bo ...

  7. jedis,spring-redis-data 整合使用,版本问题异常以及解决。

    最近整合使用redis spring-redis 出现了一下问题 spring:3.2.4.RELEASE jedis: jedis  2.4.2 spring-data-redis: 1.5.2.R ...

  8. DeepLearning之路(二)SoftMax回归

    Softmax回归   1. softmax回归模型 softmax回归模型是logistic回归模型在多分类问题上的扩展(logistic回归解决的是二分类问题). 对于训练集,有. 对于给定的测试 ...

  9. 实验一《开发环境的熟悉》&实验二《固件设计》

    20145312&20145338 实验一<开发环境的熟悉>&实验二<固件设计> 合作博客链接:http://www.cnblogs.com/yx2014531 ...

  10. 64位Win7系统下vs2010调试无法连接oracle

    64位win7系统的Program Files (x86)路径中有括号,oracle不认识这样的路径,所以就出现不能连接数据库的问题.所以我们可以将vs2010的内部调试web服务器WebDev.We ...