GithubHelp home page GithubHelp logo

estragonia's Introduction

Estragonia: Avalonia in Godot

Avalonia + Godot

NuGet

Estragonia is a bridge allowing the use of the powerful Avalonia UI framework in the no less powerful Godot game engine!

It's GPU accelerated using Vulkan, which is the main renderer used in Godot 4.

Quick Start

  1. Have Godot 4.2.2 with .NET support installed.
  2. Install the JLeb.Estragonia NuGet package inside your Godot C# project.
  3. Initialize the Avalonia application using UseGodot().SetupWithoutStarting().
  4. Add a Godot Control node to your scene, assign it a script inheriting from JLeb.Estragonia.AvaloniaControl and populate its Control property with any valid Avalonia view.

For a more detailed guide, see the step by step instructions.

Resources

For various things to know regarding compatibility, rendering and input handling, see this document.

Samples:

  • HelloWorld: a basic Avalonia-into-Godot setup.
  • GameMenu: a functional game menu UI using the MVVM pattern, with controller support, UI animations and scaling.

License

The whole Estragonia project source code is under the MIT License.
Some specific licenses may apply to some assets used in the samples. See each sample for more information.

Video

estragonia_gamemenu_demo.mp4

From the GameMenu sample

estragonia's People

Contributors

mrjul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

estragonia's Issues

Estragonia specifically requires Avalonia.Skia v 11.0.5

image

Specifically requiring Avalonia.Skia 11.0.5 means I cannot upgrade the version of Avalonia without lots of warnings from the build pipeline.

Is there a reason you've stated you wanted Skia 11.0.5 specifically, and not >= 11.0.5?

Visual Studio Designer Issue (with workaround)

The designer appears to be looking for the output of the ExportDebug configuration regardless of what configuration is selected.

When in "Debug" the following appears in the avalonia output window:

08:42:02.229 [Information] 0 Starting previewer process for '"C:\xxx.godot\mono\temp\bin\ExportDebug\GREM.dll"'
08:42:02.233 [Information] 18532 Started previewer process for '"xxx.godot\mono\temp\bin\ExportDebug\GREM.dll"'. Waiting for connection to be initialized.

The helloWorld example has the same issue:
08:56:28.443 [Information] 0 Starting previewer process for '"xxx\Estragonia\samples\HelloWorld.godot\mono\temp\bin\ExportDebug\HelloWorld.dll"'

A normal avalonia project appears to check the correct configuration:
08:54:22.145 [Information] 0 Starting previewer process for '"xxx\AvaloniaApplication1\AvaloniaApplication1.Desktop\bin\Debug\net7.0\AvaloniaApplication1.Desktop.dll"'

Switching configurations and working in "ExportDebug" allows it to work normally. I'm not sure of the origin of "ExportDebug". It's not a configuration I added to the project. It does not exist in an avalonia ui project created normally.

The helloworld example designer didn't work because it couldn't find "avalonia.png". It did work when I ran it, and after some investigation, the fix was to add a / to the image source:
<Image Source="/Avalonia.png" Width="64" Height="64" VerticalAlignment="Center" Grid.Column="0" />

CS9077 and CS8350 errors in auto generated godot files

Not sure what i'm missing from the tutorial. I've gone through it several times, but my project won't build.

Error CS8350 This combination of arguments to 'AvaloniaControl.InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)' is disallowed because it may expose variables referenced by parameter 'method' outside of their declaration scope GREM Godot.SourceGenerators\Godot.SourceGenerators.ScriptMethodsGenerator\Grem.Scenes.UserInterface_ScriptMethods.generated.cs 33 Active

Error CS9077 Cannot return a parameter by reference 'method' through a ref parameter; it can only be returned in a return statement GREM Godot.SourceGenerators\Godot.SourceGenerators.ScriptMethodsGenerator\Grem.Scenes.UserInterface_ScriptMethods.generated.cs 33 Active

The auto generated code in question is:

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret) { if (method == MethodName._Ready && args.Count == 0) { _Ready(); ret = default; return true; } if (method == MethodName._Process && args.Count == 1) { _Process(global::Godot.NativeInterop.VariantUtils.ConvertTo<double>(args[0])); ret = default; return true; } **return base.InvokeGodotClassMethod(method, args, out ret);** }

Any idea on where to start fixing this?

Allow click through on transparent areas

Hey there I just found out, that there is an issue if you overlay an Avalonia control with transparency on top of other Godot nodes.

I think it would be useful to override _HasPoint on the AvaloniaControl and execute a hit test against Avalonia. This way you can stack multiple layers of Avalonia/Godot controls on top of each other.

It is actually very simple to do using this method:

public override bool _HasPoint(Vector2 point)
{
    return Control?.InputHitTest(point.ToAvaloniaPoint()) is not null;
}

Unable to use Estragonia on macOS due to Vulkan dependency

Environment:

  • Operating System: macOS M3 Pro
  • Godot version: 4.2.2

Issue Description:
When attempting to run the Estragonia sample project on macOS, an error occurs stating that the Vulkan DLL cannot be loaded. This appears to be due to macOS not natively supporting Vulkan.

Error Message:
ERROR: System.DllNotFoundException: Unable to load shared library 'libvulkan' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable:

Steps to Reproduce:

  1. Clone the Estragonia sample project
  2. Open the project in Godot on macOS
  3. Attempt to run the project
  4. Observe the Vulkan-related error

Question:
Is it currently possible to use Estragonia on macOS? If not, are there any plans to support macOS in the future?

Thank you for your time and consideration.

Leverage Skia Context outside of the GUI

I was hoping to leverage the skia context provided by this library outside of a render-pass to generate at runtime sprites of varying detail depending on the user's settings, or perhaps to use the skia context to render vector geometry in interesting ways at runtime (like for warning indicator hitbox hints or similar)

Looking at the API surface, is that possible?

How difficult would it be to have Godot entities that draw themselves using a skia API?

PushRenderOptions error on run

Followed the setup instructions and compared against the HelloWorld example in my own project, but am getting the following error:

System.TypeLoadException
  HResult=0x80131522
  Message=Method 'PushRenderOptions' in type 'Avalonia.Skia.DrawingContextImpl' from assembly 'Avalonia.Skia, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b' does not have an implementation.
  Source=Avalonia.Skia
  StackTrace:
   at Avalonia.Skia.SkiaGpuRenderTarget.CreateDrawingContext() in /_/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs:line 37
   at Avalonia.Rendering.Composition.Server.ServerCompositionTarget.Render()

Any idea what might cause this issue?

(Using Godot 4.1.1 on Windows 10)

Failure to render UI Controls on Remote Desktop Terminal Sessions (RDP)

The Avalonian control does not render correctly on remote terminal services, even when a valid GPU adapter is available.

I initially thought I was configuring it wrong, but it works fine on regular user sessions.

If I repeatedly invalidate controls, I will occasionally get a flicker of the Avalonian content, but aside from that I see nothing from Avalonia.

Estragonia on regular windows session

image


Estragonia on windows terminal session

image

Godot reports that a valid Vulkan device is present.

Possible to use Avalonia's StorageProvider to open file picker?

Hey, this has been working fantastically so far!
I was wondering though if it would be possible to add support for opening the file picker via the StorageProvider class from Avalonia?
I am assuming it doesn't right now because the platform is not being registered as a desktop with Avalonia?
(Avalonia docs for storage provider platforms)

Totally get if it isn't really feasible. If that is the case, it might be wroth mentioning in the to know section on github.

Thanks!

AMD GPU corrupted rendering

Hey there I wanted to try out this awesome addon, but unforutnately it seems like this addon is no longer working correctly with godot 4.2

I tried to fix it using the new Texture2Drd but can't figure out what is wrong with your code.
Maybe there could be an update soonish?

2023-09-15 20_53_47-HelloWorld (DEBUG)

Help: Embed Godot controls inside an Avalonia container

Hey there sorry to bother you with this but maybe you have another genious idea how to do this.

I want to render a SubViewPortContainer as an Avalonia control.
The best thing I could imagine would be a wrapper control to render CanvasItems on the AvaloniaCanvas but with z-Index support.

My first thought was to just create a CanvasItem and render it this way, but this obviously means I can't render AvaloniaControls on top of it. Do you have an Idea how to do this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.