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. 使用celery之深入celery配置(转)

    原文:http://www.dongwm.com/archives/shi-yong-celeryzhi-shen-ru-celerypei-zhi/ 前言 celery的官方文档其实相对还是写的很不 ...

  2. nginx 负载均衡策略

    nginx 负载均衡策略   1. 轮询轮询方式是nginx负载均衡的默认策略,根据每个server的权重值来轮流发送请求,例如:upstream backend {server backend1.e ...

  3. block(闭包)

    使用方式 1定义为类的属性 最后用来发布通知,执行block即可 甚至同时发送数据参数,给方法调用者,这样返回数据比返回值形式,更好, 因为这样传参,不是同步的,而是异步响应式的,更加灵活安全. 2定 ...

  4. CSS 3 动画2D

    动画分为两种,1,逐帧动画  组成动画的每一个画面就是一帧 2,关键帧动画,确定关键帧电脑会自动过度 动画中如果遇到不兼容的问题也是要加前缀 @-webkit-keyframes规则   @-webk ...

  5. Listview 隐藏item

    隐藏某一项item(防止list改变后导致复用convertview而错乱--如果删掉list中的该项,会导致复用convertview混乱) 方法: convertView.setVisibilit ...

  6. linux 安装 apache2.2.31

    Linux下安装和配置Apache 概要:本文介绍在CentOS5.4 Linux中安装和配置Apache2.2.14,并且实现Apache和Tomcat6的整合.文章分为三部分,分别是删除系统自带的 ...

  7. HTML5和CSS3登录页面制作实录

    本文详细介绍使用HTML5 和CSS3 制作一个登录页面的完整过程. View demo login.html <form id="login"> <h1> ...

  8. python的函数及参数

    函数式编程最重要的是增强代码的重用性和可读性 def 函数名(参数): ... 函数体 ... 函数的定义主要有如下要点: def:表示函数的关键字 函数名:函数的名称,日后根据函数名调用函数 函数体 ...

  9. C#获取参数getParameter

    昨天遇到了这样一个问题,getParameter时,首次进入页面读取默认值时,本应该读取到“全部”这个字符. 然后在实际读取过程当中却不是这样,实际读取到的是  类的对象值 重新运行时能够读取到 “全 ...

  10. Masonry使用注意篇

    简要 自动布局最重要的是约束:UI元素间关系的数学表达式.约束包括尺寸.由优先级和阈值管理的相对位置.它们是添加剂,可能导致约束冲突 .约束不足造成布局无法确定 .这两种情况都会产生异常. 使用前:A ...