IsPointerUi
格式
IsPointerUi() --PC端检测鼠标
IsPointerUi(fingerId) --移动端检测触摸
- 函数
- 所属对象:UserInputService
只有客户端脚本可访问
简介
参数
变量名称 | 类型 | 默认 | 描述 |
---|---|---|---|
fingerId | int | Touch.fingerId |
返回值
类型 | 描述 |
---|---|
bool | 是否指向UI |
实例
实例1:检测鼠标的位置是否处于UI区域
wait(1)
local uis=GetService("UserInputService") --获取用户输入服务
GameRun.Update:Connect(function()
if uis:IsPointerUi() then
print("鼠标处于UI区域")
else
print("鼠标处于非UI区域")
end
end)
实例2:检测触摸的位置是否处于UI区域
wait(1)
local uis=GetService("UserInputService") --获取用户输入服务
GameRun.Update:Connect(function()
if uis:IsPointerUi(uis.GetTouch(1).fingerId) then --判断触摸屏接收到的第一个触摸点的位置是否处于UI区域
print("触摸点处于UI区域")
else
print("触摸点处于非UI区域")
end
end)
文档更新时间: 2020-07-11 14:25 作者:王辰剑