UserSettings
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
UserSettings, tüm oyunlar için temel kullanıcı ayarlarını depolamak için kullanılan tek bir nesne'dir. Şu anda sadece UserGameSettings nesnemi depolar.
Bu nesneye bir referans alabilirsiniz bu nesneyi UserSettings() işlevi aracılığıyla geri alabilirsiniz.
Kod Örnekleri
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)
Özet
Özellikler
Yöntemler
Belirlenen kullanıcı özelliği etkinleştirilmişse geri döndürür. Kullanıcı özelliği mevcut değilse bir hata oluşur.
UserSettings'ın kaydedilmiş devletini siler ve varsayılan değerlerini geri koyar.
Zaten oluşturulmuşsa verilen kullanıcı adına özel hizmeti döndürür, geçersiz bir isim için hatalar oluşur.
İstek edilen klas ismiyle hizmeti geri döndürür, mevcut değilse oluşturur.
Etkinlikler
Şuradan alınan Etkinlikler: ServiceProviderMevcut yerden çıktığında ateş eder.
Bir hizmet oluşturulduğunda ateşlenir.
Bir hizmet yaklaşık olarak kaldırılmaya çalışıldığında başlatılır.
Özellikler
Yöntemler
IsUserFeatureEnabled
Belirlenen kullanıcı özelliği etkinleştirilmişse geri döndürür. Kullanıcı özelliği mevcut değilse bir hata oluşur.
Bu işlev bir list of Flags'a karşı kullanılır, whose name starts with "User". Bu işlev Roblox tarafından oluşturulan scriptler ve işlevleri gibi kullanılır.
Parametreler
Dönüşler
Kod Örnekleri
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
Kullanıcı Ayarlarının kaydedilmiş devletini siler ve değerlerini varsayılana döndürür. Bu işlev, yerel kriptten Class.UserGameSettings sınıfının tüm özelliklerini döndürme izni olmadığından doğru bir şekilde çalışmaz.