使用者遊戲設定是一個在 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
Fullscreen
GraphicsOptimizationMode
GraphicsQualityLevel
HasEverUsedVR
MasterVolumeStudio
MaxQualityEnabled
OnboardingsCompleted
PartyVoiceVolume
RCCProfilerRecordFrameRate
RCCProfilerRecordTimeFrame
StartMaximized
StartScreenPosition
StartScreenSize
UsedCoreGuiIsVisibleToggle
UsedCustomGuiIsVisibleToggle
UsedHideHudShortcut
VREnabled
VRRotationIntensity
VRSmoothRotationEnabled
VignetteEnabled
方法
GetOnboardingCompleted
檢查是否已完成指定的培訓,這有助於避免再次顯示培訓動畫。
如果 onboardingId 不是接受的 ID 之一,就會發生錯誤。
整合過程是單向的。這意味著,作為開發人員,您可以強制整合過程完成,但無法重置它。
也見:
參數
要查詢的入門 ID。
返回
特定的入門是否已完成。
SetCameraYInvertVisible
如果呼叫,Roblox 將切換選單選項以反轉使用者的相機軸。
返回
SetGamepadCameraSensitivityVisible
如果呼叫,Roblox 將切換選單選項來控制遊戲板的相機靈敏度。
返回
SetOnboardingCompleted
將給定的培訓設為完成,因此下次玩家玩 遊玩時不會再顯示給用戶。
目前,此功能只接受 動態拇指,用於持續跟蹤玩家是否已完成動態拇指控制方案的教學。如果 onboardingId 不是接受的 ID 之一,就會發生錯誤。
整合過程是單向的。這意味著,作為開發人員,您可以強制整合過程完成,但無法重置它。
也見:
- UserGameSettings:GetOnboardingCompleted() , 檢查是否已完成新手教學
參數
設為完成的搭載ID。
返回
活動
FullscreenChanged
如果使用者的全螢幕模式變更,就會發生火災。事件只會在能夠切換全螢幕模式的桌面設備上發射。遊戲會永遠在手機和主機上的全螢幕模式。
參數
範例程式碼
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)