UserSettings 是一个唯一的对象,用于房屋基本用户设置,这在所有游戏中保持一致。目前,它只存储 UserGameSettings 对象。
您可以通过 UserSettings() 函数调用此对象的引用来取回它,该函数将它返回。
代码示例
IsUserFeatureEnabled Sample
if UserSettings():IsUserFeatureEnabled("UserNoCameraClickToMove") then
print("'ClickToMove' should no longer be loaded from the CameraScript!")
else
print("'ClickToMove' is still loaded from the CameraScript!")
end
Full Screen Mode Detection
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)
UserGameSettings Listener
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)
概要
方法
如果指定的用户功能已启用,返回 true 。如果用户功能不存在,将发生错误。
清除用户设置的保存状态,并恢复其默认值。
如果已经创建,返回指定的服务名,如果是一个无效名称,则会发生错误。
返回服务,要求指定的类别名,如果它不存在,创建它。
属性
方法
IsUserFeatureEnabled
如果指定的用户功能已启用,返回 true 。如果用户功能不存在,将发生错误。
此函数检查对一个列表的旗帜,其名称以“GlobalSettings:GetFFlag()”开头。该函数是用于Roblox创建的脚本,并且与GlobalSettings:GetFFlag()相同。
参数
返回
代码示例
IsUserFeatureEnabled Sample
if UserSettings():IsUserFeatureEnabled("UserNoCameraClickToMove") then
print("'ClickToMove' should no longer be loaded from the CameraScript!")
else
print("'ClickToMove' is still loaded from the CameraScript!")
end
属性继承自ServiceProvider
活动
属性继承自ServiceProvider