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. 小计-git

    今天在发布项目的时候遇到了一个问题,就是项目一直提示与最新版本有差异,导致发布不不成功.仔细考虑了一下,自己这次的开发与原来的是不一样的,父子工程,不是单模块开发,发现原来是别人发布过他们的模块到ma ...

  2. mybatis 模糊查询 like

    1.  参数中直接加入%% param.setUsername("%CD%");      param.setPassword("%11%"); <sel ...

  3. 转!!log4j基础

    log4j组件介绍 Log4j主要有三个组件: Logger:负责供客户端代码调用,执行debug(Object msg).info(Object msg).warn(Object msg).erro ...

  4. 小韦XPSP3 V10.0_Ghost精简版

    小韦XPSP3 V10.0_Ghost精简版 该版本基于小韦XPSP3 V10.0,用EasySysprep_4.1进行重新封装,最大程度保持原版极度精简的理念.C盘为NTFS格式,安装后C盘只占用2 ...

  5. Web1.0、Web2.0、Web3.0的主要区别

    Web1.0:以静态.单向阅读为主,网站内信息可以直接和其他网站信息进行交互,能通过第三方信息平台同时对多家网站信息进行整合使用. Web2.0:以分享为特征的实时网络,用户在互联网上拥有自己的数据, ...

  6. Python之路 day2 字符串函数

    #Author:ersa name = "ersa" #首字母大写capitalize() print(name.capitalize()) name = "my nam ...

  7. JS重要知识点

    这里列出了一些JS重要知识点(不全面,但自己感觉很重要).彻底理解并掌握这些知识点,对于每个想要深入学习JS的朋友应该都是必须的. 讲解还是以示例代码搭配注释的形式,这里做个小目录: JS代码预解析原 ...

  8. LINQ 嵌套查询

    直接代码: //获取教材下的章跟篇 IList<Chapter> chapters = EntAppFrameWorkContext.DomainModelService.ExtenedS ...

  9. IBatis.Net XML文件配置

    一.添加Provider.config <?xml version="1.0" encoding="utf-8"?> <providers x ...

  10. Android调用相册拍照控件实现系统控件缩放切割图片

    android 下如果做处理图片的软件 可以调用系统的控件 实现缩放切割图片 非常好的效果 今天写了一个demo分享给大家 package cn.m15.test; import java.io.By ...