码迷,mamicode.com
首页 > Web开发 > 详细

JSBinding / Code Snippets

时间:2016-07-05 18:41:29      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

new a gameobject & overloaded methds

var go1 = new UnityEngine.GameObject.ctor();
var go2 = new UnityEngine.GameObject.ctor$$String("Hello");

add/get c# component

var image = go.AddComponent$1(UnityEngine.UI.Image.ctor);
var image = go.GetComponent$1(UnityEngine.UI.Image.ctor);

add/get javascript component

 

define a javascript monobehaviour

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 () {
    }
});

use Inspector

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!");
});

 

JSBinding / Code Snippets

标签:

原文地址:http://www.cnblogs.com/answerwinner/p/5644493.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!