UserSettings

Mostrar obsoleto

*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.

No creable

UserSettings es un objeto singleton que se usa para almacenar las configuraciones básicas del usuario, que persisten en todos los juegos.Actualmente, solo almacena el objeto UserGameSettings .

Puedes recuperar una referencia a este objeto a través de la función UserSettings(), que lo devuelve.

Muestras de código

A basic sample of how the IsUserFeatureEnabled function is used by Roblox to control certain features.

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

A LocalScript that demonstrates how you can detect whether a game is in full screen or not.

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)

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.

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)

Resumen

Métodos

  • Devuelve verdadero si la función de usuario especificada está habilitada. Esto generará un error si la función de usuario no existe.

  • Reset():()

    Borra el estado guardado de las configuraciones de usuario y restaura sus valores predeterminados.

Métodos heredados de ServiceProvider
  • Escribir paralelo

    Devuelve el servicio especificado por el className dado si ya se ha creado, errores por un nombre inválido.

  • Devuelve el servicio con el nombre de clase solicitado, creándolo si no existe.

Eventos

Eventos heredados de ServiceProvider

Propiedades

Métodos

IsUserFeatureEnabled

Devuelve verdadero si la función de usuario especificada está habilitada. Esto generará un error si la función de usuario no existe.

Esta función comprueba contra una lista de FFlags, cuyo nombre comienza con "Usuario".La función está destinada a ser utilizada por scripts creados por Roblox y funciona de manera similar a GlobalSettings:GetFFlag() .

Parámetros

name: string
Valor predeterminado: ""

Devuelve

Muestras de código

A basic sample of how the IsUserFeatureEnabled function is used by Roblox to control certain features.

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

Reset

()

Borra el estado guardado de las configuraciones de usuario y restaura sus valores de nuevo a la configuración predeterminada.Esta función fallará al ejecutarse correctamente desde un LocalScript, ya que no tiene permiso para restaurar todas las propiedades en la clase UserGameSettings.


Devuelve

()

Eventos