お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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.
CloseOnMouseEnterはGUIElementまたはCollider上にマウスが乗った時に呼び出されます
// Attach this script to a mesh to make // it red when the mouse is over the mesh function OnMouseEnter () { renderer.material.color = Color.red; }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void OnMouseEnter() { renderer.material.color = Color.red; } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def OnMouseEnter() as void: renderer.material.color = Color.red
この関数はレイヤーが「Ignore Raycast」のゲームオブジェクトでは呼び出されません。 OnMouseEnterは関数の中にシンプルなyield文を使用して、コルーチンにすることができます。 このイベントはColliderまたはGUIElementにアタッチされているすべてのスクリプトに送信されます。