学习
引擎类
UserSettings
无法创建

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


概要
继承成员
代码示例
IsUserFeatureEnabled 示例
if UserSettings():IsUserFeatureEnabled("UserNoCameraClickToMove") then
print("'ClickToMove' 不应该再从 CameraScript 加载!")
else
print("'ClickToMove' 仍然从 CameraScript 加载!")
end
全屏模式检测
local gameSettings = UserSettings().GameSettings
local function checkFullScreenMode()
local inFullscreen = gameSettings:InFullScreen()
if inFullscreen then
print("全屏模式已启用!")
else
print("全屏模式已禁用!")
end
end
checkFullScreenMode()
gameSettings.FullscreenChanged:Connect(checkFullScreenMode)
用户游戏设置监听器
local gameSettings = UserSettings().GameSettings
local function onGameSettingChanged(nameOfSetting)
-- 通过 pcall 获取此设置的值,以确保我们可以检索它。
-- 有时事件会在 LocalScripts 无法访问的属性下触发。
local canGetSetting, setting = pcall(function()
return gameSettings[nameOfSetting]
end)
if canGetSetting then
print("您的 " .. nameOfSetting .. " 已更改为: " .. tostring(setting))
end
end
gameSettings.Changed:Connect(onGameSettingChanged)

API 参考
方法
IsUserFeatureEnabled
功能: Players
UserSettings:IsUserFeatureEnabled(name:string):boolean
参数
name:string
返回
代码示例
IsUserFeatureEnabled 示例
if UserSettings():IsUserFeatureEnabled("UserNoCameraClickToMove") then
print("'ClickToMove' 不应该再从 CameraScript 加载!")
else
print("'ClickToMove' 仍然从 CameraScript 加载!")
end

Reset
功能: Players
UserSettings:Reset():()
返回
()

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