用户游戏设置是一个在 UserSettings 单元中找到的单例类。它保持与用户如何控制相镜头和角色相关的各种持续设置。
您可以通过以下方式访问此对象:LocalScript
UserSettings():GetService("UserGameSettings")
该对象仅用于客户端,因为它在服务器上没有任何用途。它还会在 Roblox Studio 中测试时反映您自己的设置。
代码示例
A basic example that shows how you can listen to changes in the user's settings. With this code pasted into a LocalScript running in the StarterPlayerScripts, you can change settings in Roblox's game menu, and see their values appear in the output as detected changes.
local gameSettings = UserSettings().GameSettings
local function onGameSettingChanged(nameOfSetting)
-- Fetch the value of this setting through a pcall to make sure we can retrieve it.
-- Sometimes the event fires with properties that LocalScripts can't access.
local canGetSetting, setting = pcall(function()
return gameSettings[nameOfSetting]
end)
if canGetSetting then
print("Your " .. nameOfSetting .. " has changed to: " .. tostring(setting))
end
end
gameSettings.Changed:Connect(onGameSettingChanged)
概要
属性
客户端在桌面上使用的当前镜头移动模式。
客户端在桌面上使用的控件类型。
切换客户端是否可以使用鼠标锁定切换模式。
描述使用游戏手柄时摄像头的灵敏度。
一个介于 0 和 1 之间的浮动代表游戏客户端的音量。
一个介于 0 和 4 之间的浮点,代表客户端相机灵敏度的敏感度。
控制客户端角色的旋转方式。
客户端设置的图形质量等级。
客户端在移动设备上使用的相机类型。
客户端在移动设备上使用的控件类型。
方法
返回相镜头的 Y 反转值。
检查入职已完成。
如果用户的 Roblox 窗口处于全屏模式,返回真值。
如果客户端的游戏会话在 Roblox Studio 中,返回真值。
如果调用,Roblox 将菜单选项切换为反转用户的相机轴。
如果调用,Roblox 将切换菜单选项以控制相机灵敏度与游戏手柄。
将入职设置为完成。
活动
如果用户更改了全屏模式,发生火灾。
当用户的客户端切换到工作室模式和游戏模式时发射。在 Roblox Studio 中,当会话开始时,会定期发射。
属性
AllTutorialsDisabled
CameraMode
ChatVisible
Fullscreen
GraphicsOptimizationMode
GraphicsQualityLevel
HasEverUsedVR
MasterVolumeStudio
MaxQualityEnabled
OnboardingsCompleted
PartyVoiceVolume
RCCProfilerRecordFrameRate
RCCProfilerRecordTimeFrame
StartMaximized
StartScreenPosition
StartScreenSize
UsedCoreGuiIsVisibleToggle
UsedCustomGuiIsVisibleToggle
UsedHideHudShortcut
VREnabled
VRRotationIntensity
VRSmoothRotationEnabled
VignetteEnabled
方法
GetOnboardingCompleted
检查是否已完成给定的入门,这对于避免再次显示入门动画有用。
如果 onboardingId 不是接受的 ID 之一,将抛出错误。
入职过程是单向的。这意味着,作为开发者,您可以强制入职过程完成,但无法重置它。
还见:
参数
要查询的入职ID。
返回
特定的入职是否已完成。
SetCameraYInvertVisible
如果调用,Roblox 将菜单选项切换为反转用户的相机轴。
返回
SetGamepadCameraSensitivityVisible
如果调用,Roblox 将切换菜单选项以控制相机灵敏度与游戏手柄。
返回
SetOnboardingCompleted
将给定的新手教程设置为已完成,因此下次玩家游游玩时不会再显示给用户。
目前,此功能仅接受 动态拇指钮 ,用于持续跟踪玩家是否已完成动态拇指控制方案的教程。如果 onboardingId 不是接受的 ID 之一,将抛出错误。
入职过程是单向的。这意味着,作为开发者,您可以强制入职过程完成,但无法重置它。
还见:
- UserGameSettings:GetOnboardingCompleted() , 检查是否已完成入职
参数
用于设置为完成的搭载 ID。
返回
活动
FullscreenChanged
如果用户更改了全屏模式,发生火灾。事件只会在能够切换全屏模式的桌面设备上发射。游戏始终会在移动设备和游戏机上处于全屏状态。
参数
代码示例
A LocalScript that demonstrates how you can detect whether a game is in full screen or not.
local gameSettings = UserSettings().GameSettings
local function checkFullScreenMode()
local inFullscreen = gameSettings:InFullScreen()
if inFullscreen then
print("Full Screen mode enabled!")
else
print("Full Screen mode disabled!")
end
end
checkFullScreenMode()
gameSettings.FullscreenChanged:Connect(checkFullScreenMode)