お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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.
CloseOnMouseOverはGUIElementまたはCollider上にマウスがあり続ける限り毎フレーム呼び出し続けます
// Fades the red component of the material to zero // while the mouse is over the mesh function OnMouseOver () { renderer.material.color -= Color(0.1, 0, 0) * Time.deltaTime; }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void OnMouseOver() { renderer.material.color -= new Color(0.1F, 0, 0) * Time.deltaTime; } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def OnMouseOver() as void: renderer.material.color -= (Color(0.1F, 0, 0) * Time.deltaTime)
この関数はレイヤーが「Ignore Raycast」のゲームオブジェクトでは呼び出されません。 OnMouseOverは関数の中にシンプルなyield文を使用して、コルーチンにすることができます。 このイベントはColliderまたはGUIElementにアタッチされているすべてのスクリプトに送信されます。