Posted on

Linux version updated (with play on Android + fully scriptable GUIs – no code compilation or tooling needed)

Linux version now supports playing scenes on Android and features fully scriptable GUI creation straight to your Android device in < 1 second (no code compilation or tooling required) for fast iteration and prototyping. v0.42.0+ includes a new GUI plugin that contains a GUISystem and GUIComponent that supports immediate mode GUIs (defined in script). You can do this in the editor by adding a GUIComponent to an object in your scene and setting its script property to a GUI script (see below) and then view immediately on your Android device:

-- an example GUI script (lua)
function update(this, time)
	windowPos = ext_GUIScript.ImVec2(0,0)
	ext_GUIScript.SetNextWindowPos(windowPos)
	window = nil
	ext_GUIScript.Begin('A Window', window)
	if ext_GUIScript.Button('Click Me!') then
	    -- do stuff in response to button click
	end
	ext_GUIScript.End()
end

You can also do this programmatically in C++ as follows:

// Add a GUIComponent to an empty GhostSceneItem and define your GUI
auto object = static_cast<GhostSceneItem*>(firefly::SDK::GetInstance().CreateSceneItem(SceneItemType_GhostSceneItem));
auto gui    = object->AddComponent<GUIComponent>();
auto script = R"(function update(this, time)
                    windowPos = ext_GUIScript.ImVec2(0,0)
                    ext_GUIScript.SetNextWindowPos(windowPos)
                    window = nil
                    ext_GUIScript.Begin('A Window', window, ext_GUIScript.ImGuiWindowFlags_AlwaysAutoResize)
                    if ext_GUIScript.Button('Click Me!') then
                        // do stuff in response to button click
                    end
                    ext_GUIScript.End()
                end)";
gui->SetScript(script);
Liked it? Take a second to support ben morris on Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *