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.
KullanıcıAyarları, tüm oyunlar arasında kalıcı olan temel kullanıcı ayarlarını barındırmak için kullanılan bir tek nesnedir.Şu anda sadece UserGameSettings nesnesini depolar.
Bu nesneye referans alabilirsiniz UserSettings() işlevi aracılığıyla, ki bunu döndürür.
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
Belirtilen kullanıcı özelliği etkinleştirildiğinde doğru döndürür. Kullanıcı özelliği mevcut değilse bir hata atılır.
Kullanıcı Ayarlarının kaydedilmiş durumunu siler ve varsayılan değerlerini yeniler.
Verilen sınıf tarafından belirtilen hizmeti geri döndürür, eğer zaten oluşturulduysa, geçersiz bir isim için hata.
Talep edilen sınıf adıyla hizmeti geri döndürür ve mevcut değilse yeni bir hizmet oluşturur.
Etkinlikler
Şuradan alınan Etkinlikler: ServiceProviderMevcut yer çıktığında ateş eder.
Bir hizmet oluşturulduğunda ateş edilir.
Bir hizmet kaldırılmak üzere olduğunda ateş edilir.
Özellikler
Yöntemler
IsUserFeatureEnabled
Belirtilen kullanıcı özelliği etkinleştirildiğinde doğru döndürür. Kullanıcı özelliği mevcut değilse bir hata atılır.
Bu işlev, "Kullanıcı" ile başlayan bir FFlaglar listesine karşı kontrol eder.İşlev, Roblox tarafından oluşturulan senaryolarda kullanılmak üzere tasarlanmıştır ve GlobalSettings:GetFFlag() 'ye benzer şekilde işlev görü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ş durumunu siler ve değerlerini varsayılana geri yerleştirir.Bu işlev, UserGameSettings sınıfındaki tüm özellikleri yeniden yükleme iznine sahip olmadığı için YerelScript'ten doğru çalışmayı başaramayacaktır.