Version: 2023.1
言語: 日本語

説明

OnMouseDown is called when the user has pressed the mouse button while over the Collider.

This event is sent to all scripts of the GameObject with Collider. Scripts of the parent or child objects do not receive this event.

using UnityEngine;

public class ExampleClass : MonoBehaviour { void OnMouseDown() { // Destroy the gameObject after clicking on it Destroy(gameObject); } }

Note: This function is not called on objects that belong to Ignore Raycast layer.

This function is called on Colliders and 2D Colliders marked as trigger when the following properties are set to true:

- For 3D physics: Physics.queriesHitTriggers

- For 2D physics: Physics2D.queriesHitTriggers

In addition, OnMouseDown can be a coroutine.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961