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 ...
随机推荐
- IOS开发之WIFI及IP相关
获取手机设备的IP信息: #import <ifaddrs.h> #import <arpa/inet.h> // Get IP Address - (NSString *)g ...
- js 默认选中分页条件项
<table border="0" cellspacing="0" cellpadding="0" height="100% ...
- android mvvm
android studio 需要gradle 1.5.0以上才支持 dependencies { classpath 'com.android.tools.build:gradle:1.5.0'} ...
- jquery获取(设置)节点的属性与属性值
1. attr(属性名) //获取属性的值(取得第一个匹配元素的属性值.通过这个方法可以方便地从第一个匹配元素中获取一个属性的值.如果元素没有相应属性,则返回 undefined ) 2 ...
- yii2-basic后台管理功能开发之二:创建CRUD增删改查
昨天实现了后台模板的嵌套,今天我们可以试着创建CRUD模型啦 刚开始的应该都是“套用”,不再打算细说,只把关键的地方指出来. CRUD即数据库增删改查操作.可以理解为yii2为我们做了一个组件,来实现 ...
- apche的主配置文件)
apche的主配置文件conf/httpd.conf(根据个人主机的路径设置,以下仅供参考) 需配置的行号与方法(示列): 172 #ServerName localhost:80 173 Serv ...
- Less基础知识~~~实现css
首先献上我学习网址 http://www.bootcss.com/lesscss.html 就是通过less.js的调用,更好的实现css样式布局,更简易化. 最近看前端的职位要求需简单理解less之 ...
- Android开发--ImageView的应用
1.简介 当要在屏幕上显示图片时,ImageView用于创建显示图片所需的对象.另外,通过设置ImageView可以改变图片的有关属性. 2.构建 使用Images & Media中的部件来实 ...
- 爱默生UPS并机系统:进入与退出操作方法
UPS并机系统的进入与退出: 进入:.合UPS的出线及进线开关:开启第一台UPS,等待整流指示灯常亮.然后Invert On,正常开机,此时UPS进入逆变状态 .合另外一台UPS的出线及进线开关,等待 ...
- bzoj 3130: [Sdoi2013]费用流
#include<cstdio> #include<iostream> #define M 10000 #define inf 0x7fffffff #include<c ...