概要
方法
DisableGamepadCursor():() |
EnableGamepadCursor(guiObject: Instance):() |
API 参考
属性
GamepadCursorEnabled
代码示例
游戏手柄服务 - 游戏手柄光标启用属性
local gamepadService = game.GamepadService
gamepadService:GetPropertyChangedSignal("GamepadCursorEnabled"):Connect(function()
local enabled = gamepadService.GamepadCursorEnabled
if enabled then
-- 当虚拟光标启用时的自定义代码
else
-- 当虚拟光标禁用时的自定义代码
end
end)方法
DisableGamepadCursor
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
参数
返回
()
代码示例
游戏手柄服务 - 启用游戏手柄光标
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)