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

スクリプト言語

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

ContextMenu

class in UnityEngine

マニュアルに切り替える

説明

ContextMenu 属性はコンテキストメニューにコマンドを追加することができます。

スクリプトがアタッチされたインスペクターで、ユーザーがコンテキストメニューを選択したとき 関数が実行されます。

これはスクリプトからシーンデータを自動的にセットアップするときにもっとも便利です。 この関数は非 static である必要があります。

@ContextMenu ("Do Something")
function DoSomething () {
	Debug.Log ("Perform operation");
}
// C# example:
public class ContextTesting : MonoBehaviour {
	/// Add a context menu named "Do Something" in the inspector
	/// of the attached script.
	[ContextMenu ("Do Something")]
	void DoSomething () {
		Debug.Log ("Perform operation");
	}
}

コンストラクタ

ContextMenuコンポーネントのコンテキストメニューに関数を追加します