UserSettings 는 모든 게임에서 기본적인 사용자 설정을 저장하는 단일 개체입니다. 현재, 그것은 단지 UserGameSettings 개체를 저장합니다.
이 개체에 대한 참조를 검색하려면 UserSettings() 함수를 호출하여 반환합니다.
코드 샘플
A basic sample of how the IsUserFeatureEnabled function is used by Roblox to control certain features.
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.
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.
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를 반환합니다. 사용자 기능이 없는 경우 오류가 발생합니다.
이 함수는 "사용자"로 시작하는 목록의 플래그 목록에 대해 검사합니다. 이 함수는 Roblox가 만든 스크립트, 함수와 유사하게 사용되도록 의도되었습니다. GlobalSettings:GetFFlag() 에 대한 함수.
매개 변수
반환
코드 샘플
A basic sample of how the IsUserFeatureEnabled function is used by Roblox to control certain features.
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
사용자 설정 및 메타 데이터를 저장하고 해당 값을 기본으로 다시 복원합니다. 이 함수는 로컬 스크립트에서 사용자 설정 및 메타 데이터를 저장하지 못하므로 실행할 수 없습니다. Class.UserGameSettings 클래스의 모든 속성을 복원하려면 로컬 스크립트에 권한이 있어야 합니다.