Introduction
InterfaceWorks is a reactive UI library made for Roblox games AND Studio plugins. It gives you as much control as possible with as little overhead as possible.
- Fast - reuses as much data as possible without breaking reactivity. Render 5k+ elements in 50ms.
- Lightweight - uses objects to store data.
- Easy to use - works like all the libraries you already know.
Why?
The biggest issue for me in libraries like this was the lack of support for DockWidgetPluginGuis. So to conquer this I made a “cross-environment” way to get APIs like GetRelativeMousePosition(), that work in both CoreGui/Screenguis and DockWidgetPluginGuis.
Materials - reusable definitions of properties without copying any code. Materials also allow per frame updates using a RenderStepped function. Something you could make is windows aero glass for example, but realistically the only limit is your imagination.
InterfaceWorks also allows custom object APIs. This could be useful for pushing data into the UI from an external system, although this method would require you to store the returned object when creating the UI. (This isn’t the only way to get external data, it’s just one of the options.)
Getting started
Installation
InterfaceWorks can be installed in 3 ways:
- Assemble the source code yourself using Rojo and DarkLua.
- Get the binary on Github releases.
- Using wally.
Usage
REMINDER - All of this and more is available on the docs page.
Code example:
local InterfaceWorks = require(game:GetService("ReplicatedStorage").InterfaceWorks)
local NewRootHost = Instance.new("ScreenGui")
NewRootHost.Parent = game.Players.LocalPlayer.PlayerGui
NewRootHost.IgnoreGuiInset = true
local NewRoot = InterfaceWorks.CreateRoot(NewRootHost)
function MyApp()
local WidthScale = InterfaceWorks.Value.New(0)
return {InterfaceWorks.CreateElement("Frame",
{
Properties={
Size = UDim2.fromScale(0.5,0.5),
AnchorPoint = Vector2.new(0.5,0.5),
Position = UDim2.fromScale(WidthScale.Value,0.5)
}
},
{
InterfaceWorks.CreateElement("TextLabel", {
Properties = {
Text = "Test Hello world!",
Size = UDim2.fromScale(1,1),
BackgroundTransparency = 1,
TextColor3 = Color3.new(1,1,1)
}
}),
}
)
}
end
NewRoot:Attach(MyApp)
Explanation:
- Require the library.
local InterfaceWorks = require(game:GetService("ReplicatedStorage").InterfaceWorks)
- Create a container for our UI.
local NewRootHost = Instance.new("ScreenGui")
NewRootHost.Parent = game.Players.LocalPlayer.PlayerGui
NewRootHost.IgnoreGuiInset = true
- Create an InterfaceWorksRoot object which we will attach our UI to.
local NewRoot = InterfaceWorks.CreateRoot(NewRootHost)
- The main function (the function we are going to render) should always return a table of elements we want to render.
return { Some elements we want to render }
- This example also uses a Value object, the 0 you see in the function arguments, is the starting point for that Value. The
.Valueproperty behaves just like the one in a ValueInstance (for example numbervalue). To access the value you do.Valueand to set it.Value = 10.
local WidthScale = InterfaceWorks.Value.New(0)
- An element’s structure is made of a Classname, { Data about our element }, { children } in this exact order.
InterfaceWorks.CreateElement("Frame",
{
Properties={
Size = UDim2.fromScale(0.5,0.5),
AnchorPoint = Vector2.new(0.5,0.5),
Position = UDim2.fromScale(WidthScale.Value,0.5)
}
}, {Children}
- Lastly we use the
:Attach()API of the InterfaceWorksRoot object to queue our render.
NewRoot:Attach(MyApp)
DISCLAIMER
This library is being actively developed, expect things to break and please be patient for updates, since this is a solo dev project, which makes it really hard to work on everything at once along with other work I have to do. The docs page is also currently in a rough shape, although I do plan to make it a lot better. If you see something missing or would like to see in this library, just make a ticket on Github and I’ll try to respond to it asap.
Currently the docs don’t have all of the features listed and documented, I will try my best to fill the docs asap, but please be patient.
Any feedback is VERY welcome and please be understanding of any mistakes, since this is my first attempt at something like this.
