I am updating my plugin and it’s currently only dark themed. I would like to have it change automatically to Light or Dark theme depending on your settings.
I thought I saw an API about dark theme and how to do this but I can’t find it.
If you know how to change a Plugin depending on the Theme, that’d be much appreciated.
Also, would it be better to just have two Plugin UIs, one Light Themed and one Dark Themed or have one UI and change all the element’s color in the code?
settings().Studio.ThemeChanged:Connect(function()
print(StudioTheme) -- It prints here
if settings().Studio.Theme == Enum.UITheme.Light then
print("It's Light") --But not here
RoundifyButton.BackgroundColor3 = Color3.new(255,255,255) --Doesn't do this either
elseif settings().Studio.Theme == Enum.UITheme.Dark then
print("It's Dark") -- Or here
RoundifyButton.BackgroundColor3 = Color3.new(46,46,46) -- Or this
end
end)
For whatever reason, my If Statement doesn’t work.
settings().Studio.ThemeChanged:Connect(function()
wait(3)
if settings().Studio["UI Theme"] == Enum.UITheme.Light then
print(settings().Studio.Theme.Name)
RoundifyButton.BackgroundColor3 = Color3.new(255,255,255)
elseif settings().Studio["UI Theme"] == Enum.UITheme.Dark then
print(settings().Studio.Theme.Name)
RoundifyButton.BackgroundColor3 = Color3.new(46,46,46)
end
print("bye")
end)
No matter what I do, it will not change it back to 46,46,46.
It will change it to 255,255,255 when you switch to light. Or if I start out as light and switch to dark, it still keeps it at 255,255,255. All of the prints are reading what you’d expect, so I have no idea what’s up.
While the answers above do work, it is NOT the recommended way of handling Studio themes! The UITheme enum is deprecated now, and it has been phased out in favor of the newer StudioTheme API.
The StudioTheme object’s has a function called GetColor, which lets you grab the pre-defined set of color themes for the selected theme. settings().Studio.Theme.Name is also the preferred technique for checking the name of the theme that is being used.