JSBinding / Code Snippets

Posted AnswerWinner

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 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的主要内容,如果未能解决你的问题,请参考以下文章

text VS Code Slick Snippets

markdown [c ++ snippets] #c ++ #code

ruby Ruby Code Snippets

json VS Code html Snippets

json VS Code php Snippets

golang Golang Code Snippets