言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

ContextMenu.ContextMenu

public function ContextMenu(name: string)

Description

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

スクリプトがアタッチされたインスペクターで、ユーザーがコンテキストメニューを選択した時、 関数が実行されます。 これはスクリプトからシーンデータを自動的にセットアップするときにもっとも便利です。 この関数は非staticである必要があります。

	@ContextMenu ("Do Something")
	function DoSomething () {
		Debug.Log ("Perform operation");
	}
	// C# example:
	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");
		}
	}