お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseOnMouseDownはGUIElementまたはCollider上でユーザーがマウスボタンをクリックした時に呼び出されます
このイベントはColliderまたはGUIElementにアタッチされているすべてのスクリプトに送信されます。
// Loads the level named "SomeLevel" as a response // to the user clicking on the object function OnMouseDown () { Application.LoadLevel ("SomeLevel"); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void OnMouseDown() { Application.LoadLevel("SomeLevel"); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def OnMouseDown() as void: Application.LoadLevel('SomeLevel')
この関数はレイヤーが「Ignore Raycast」のゲームオブジェクトでは呼び出されません。 OnMouseDownは関数の中にシンプルなyield文を使用して、コルーチンにすることができます。 このイベントはColliderまたはGUIElementにアタッチされているすべてのスクリプトに送信されます。