Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

MenuCommand

class in UnityEditor

マニュアルに切り替える

説明

MenuItem でコンテキストを展開するために使用されます。MenuCommand オブジェクトは、MenuItem 属性を使用して定義されたカスタムメニューアイテムの関数に渡されます。

// Add context menu named "Something" to context menu
@MenuItem ("CONTEXT/Rigidbody/Do Something")
static function Something (command : MenuCommand) {
	var body : Rigidbody = command.context;
	body.mass = 5;
	Debug.Log ("Changed Rigidbody's Mass to " + body.mass + " from Context Menu...");
}

See Also: MenuItem.

変数

contextコンテキストはメニューコマンドのターゲット(現在選択しているオブジェクト、など)となるオブジェクトです
userDataメニューアイテムにカスタム情報を渡すための integer

コンストラクタ

MenuCommand新規の MenuCommand オブジェクトを作成します