egui
, the scripts need to run every frame (average of 60 fps atleast).use once
objects, which means lots of garbage collectable objects for a reasonably complex ui script. It is also expensive to create/recreate these objects every frame.
Window::new("hello")
or RichText::new("text").color(egui.blue)
etc..ui
fn like Response
also create userdata objects.&mut Ui
needs to create a new userdata object to bind that reference to.Rect
will need to be userdata.This project might still work for some people, and I would encourage them to fork this repo. But I would like to experiment with retained mode toolkits now, where you only scripts on events.
egui bindings for mlua.
Just look at the example for basic usage. You can play with the web version live at https://coderedart.github.io/luaegui/
There should be a window called Script Editor
where you can edit the lua code live within egui.
After editing the code, just click the run
button on top to execute that code in the lua vm.
If there was any error, it will be printed to stdout/console(on web).
Below the code editor, you can see how long the gui_run
fn takes every frame.
Every frame, the example will try to call the gui_run
fn (if it exists) and gives it egui context as the argument.
If the fn fails for some reason, the error will be printed to stdout/console.
We provide a global table called egui
which contains most constants + types + functions to be used by lua scripts.
for example, you can create a Window
using local window = egui.window.new("my window title");
Because we don't really have a way to properly document host api in mlua yet, we will do this manually. For now, we provide a type definition file (WIP) egui.d.lua
.
Luau Language Server
extension by JohnnyMorganz
in vscodeegui.d.lua
file from thi repo to your lua project folderluau-lsp.types.definitionFiles
, add the file egui.d.lua