Currently, Estragonia targets Avalonia 11.2.3 and Godot 4.3.0.
Don't try to use Estragonia with unsupported Avalonia versions. In general, avoid referencing Avalonia directly when possible. Since Estragonia implements a backend for Avalonia, it targets some API that are semi-private and may change in future minor Avalonia releases.
For Godot, you should be fine referencing the latest bug fix release, e.g. Godot 4.3.x. For major updates (e.g. Godot 4.4), you'll probably need to wait for a compatible Estragonia version to be released.
Only the Vulkan renderers from Godot 4 are supported: these are the Forward+ and Mobile renderers.
The Compatibility renderer is NOT supported.
Estragonia leverages the Skia backend from Avalonia to render the controls, which outputs a texture having a premultiplied alpha channel.
By default, if no material is set on the AvaloniaControl
, Estragonia automatically creates a CanvasItemMaterial
with a BlendMode
sets to PremultAlpha
so there's nothing special to do. If you need to set a custom material instead, ensure it has the correct blend mode, or semi-transparency won't work correctly.
To scale your UI, change the RenderScaling
property of the AvaloniaControl
.
If you need to access the texture containing the rendered Avalonia UI, for example to use it as a material's texture, call AvaloniaControl.GetTexture()
. To make sure the texture is up-do-date, please read Godot's documentation for Viewport.GetTexture: the same constraints apply here.
To be able to use the keyboard inside Avalonia controls, make sure Godot's Control.FocusMode
property is set to All
.
To be able to input emojis and use the IME, call Godot's Window.SetImeActive(true)
method.
Game controller input from Godot are mapped to three Avalonia routed events in the JLeb.Estragonia.Input.JoypadEvents
class:
JoypadButtonDownEvent
when a button is pressedJoypadButtonUpEvent
when a button is releasedJoypadAxisMovedEvent
when an axis (stick or trigger) moves
Use AddHandler
to handle these events.
By default, some Godot input actions are automatically mapped to an Avalonia InputElement.KeyDownEvent
:
Action | Key |
---|---|
ui_left |
Key.Left |
ui_right |
Key.Right |
ui_up |
Key.Up |
ui_down |
Key.Down |
ui_accept |
Key.Enter |
ui_cancel |
Key.Escape |
Implement proper keyboard handling and you should have controller UI support for free. Make sure the controller buttons are properly mapped to the built-in UI actions in Godot Project ⇒ Project Settings ⇒ Input Map
.
This is the technique used in the GameMenu sample.
If you prefer to disable this behavior and handle everything manually instead, set AutoConvertUIActionToKeyDown
to false
in the AvaloniaControl
.