Version: 2021.3
public static int hotControl ;

描述

当前热控件的 controlID。

热控件指的是暂时激活的控件。当用户在某个按钮上按下鼠标按钮时,该按钮“变热”。\ 当某个控件处于热状态时,不允许其他控件响应鼠标事件。\ 当用户松开鼠标按钮时,该控件将 hotControl 设置为 0,以指示其他控件现在可以响应用户输入。

using UnityEngine;

public class Example : MonoBehaviour { // Click on the button to see the id

void OnGUI() { GUILayout.Button("Press Me!"); Debug.Log("id: " + GUIUtility.hotControl); } }