描述

当用户在 GUIElementCollider 上按下鼠标按钮时,将调用 OnMouseDown

该事件将发送到 ColliderGUIElement 的所有脚本。

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class ExampleClass : MonoBehaviour { void OnMouseDown() { SceneManager.LoadScene("OtherSceneName"); } }

在属于 Ignore Raycast 层的对象上,不调用该函数。

当且仅当 Physics.queriesHitTriggers 为 true 时,才在标记为触发器的碰撞体上调用该函数。

OnMouseDown can be a co-routine.


This event is sent to all scripts attached to the Collider or GUIElement.

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