学习
引擎类
GamepadService
无法创建
服务
未复制

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处


概要
继承成员

API 参考
属性
GamepadCursorEnabled
Roblox 脚本安全性
读取并联
功能: Input
GamepadService.GamepadCursorEnabled:boolean
代码示例
游戏手柄服务 - 游戏手柄光标启用属性
local gamepadService = game.GamepadService
gamepadService:GetPropertyChangedSignal("GamepadCursorEnabled"):Connect(function()
local enabled = gamepadService.GamepadCursorEnabled
if enabled then
-- 当虚拟光标启用时的自定义代码
else
-- 当虚拟光标禁用时的自定义代码
end
end)

方法
DisableGamepadCursor
功能: Input
GamepadService:DisableGamepadCursor():()
返回
()
代码示例
游戏手柄服务 - 禁用游戏手柄光标
local gamepadService = game.GamepadService
local userInputService = game.UserInputService
userInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.ButtonB then
gamepadService:DisableGamepadCursor()
end
end)

EnableGamepadCursor
功能: Input
GamepadService:EnableGamepadCursor(guiObject:Instance):()
参数
guiObject:Instance
返回
()
代码示例
游戏手柄服务 - 启用游戏手柄光标
local gamepadService = game.GamepadService
local userInputService = game.UserInputService
local startObject = script.Parent
userInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.ButtonA then
gamepadService:EnableGamepadCursor(startObject)
end
end)

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。