使用者遊戲設定是一個在 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
ComputerCameraMovementMode
ComputerMovementMode
Fullscreen
GamepadCameraSensitivity
GraphicsOptimizationMode
GraphicsQualityLevel
HasEverUsedVR
MasterVolume
MasterVolumeStudio
MaxQualityEnabled
MouseSensitivity
OnboardingsCompleted
PartyVoiceVolume
RCCProfilerRecordFrameRate
RCCProfilerRecordTimeFrame
RotationType
SavedQualityLevel
StartMaximized
StartScreenPosition
StartScreenSize
TouchCameraMovementMode
TouchMovementMode
UsedCoreGuiIsVisibleToggle
UsedCustomGuiIsVisibleToggle
UsedHideHudShortcut
VREnabled
VRRotationIntensity
VRSmoothRotationEnabled
VignetteEnabled
方法
活動
FullscreenChanged
參數
範例程式碼
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)