我要加入

UNITY3D聖殿-自由的遊戲設計天堂

會長:stormcorn / stormcorn開設日:2013-03-21 18:05:22

  • EXP

  • 資金24253  
  • 招募制度:自由加入制
  • 成員:1737 人
  • 昨日人氣:0

UnityScript對照C#

推上精選編輯

近期編輯:ADSL1234567B ...看更多

UnityScript (JS) 對照 C#

範例一

#pragma strict

// UnityScript
class Person {
    var transform : Transform;
    var name : String;
    var height : int;

    function Goto(position : Vector3) {
        transform.position = position;
    }
};

// C#
public class Person
{
    public Transform transform;
    public string name;
    public int height;

    public void Goto(Vector3 position)
    {
        transform.position = position;
    }
}

範例二

// UnityScript
// File: OffsetExample.js
#pragma strict

var position : Vector3;
var yOffset : float;

function GetOffsetPosition() : Vector3 {
    var p : Vector3 = transform.position;
    return Vector3(p.x, p.y + yOffset, p.z);
}

// C#
public class OffsetExample : MonoBehaviour
{
    public Vector3 position;
    public float yOffset;

    public Vector3 GetOffsetPosition()
    {
        // 等同 Vector3 p = transform.position;
        var p = transform.position;
        return new Vector3(p.x, p.y + yOffset, p.z);
    }
}

公會首頁

主選單
關聯資料

目前沒有資料連到「UnityScript對照C#」。


face基於日前微軟官方表示 Internet Explorer 不再支援新的網路標準,可能無法使用新的應用程式來呈現網站內容,在瀏覽器支援度及網站安全性的雙重考量下,為了讓巴友們有更好的使用體驗,巴哈姆特即將於 2019年9月2日 停止支援 Internet Explorer 瀏覽器的頁面呈現和功能。
屆時建議您使用下述瀏覽器來瀏覽巴哈姆特:
。Google Chrome(推薦)
。Mozilla Firefox
。Microsoft Edge(Windows10以上的作業系統版本才可使用)

face我們了解您不想看到廣告的心情⋯ 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】