segross / UnrealImGui

Unreal plug-in that integrates Dear ImGui framework into Unreal Engine 4.
MIT License
666 stars 211 forks source link

Question not directly related to UnrealImGui (Porting Ultralight to UE) #51

Closed Zenahr closed 3 years ago

Zenahr commented 3 years ago

Hi @segross!

Great work that you've done with UnreallImGui! I'm currently contemplating on creating Unreal Engine bindings for the HTML5 rendering engine https://ultralig.ht/ Reason being that this would allow web developers to create user interfaces using web technologies. This would simplify and streamline a lot of UI work I believe and at least for me personally, this would make it much easier and less error prone to work with dynamic data (e. g. a list for servers that users could join)

I'm a novice C++ programmer though and the task seems daunting to me. I've looked at some of your commits on UnrealImGui but I personally wouldn't know where to start on my project.

So I was thinking if you could give me your insights into how much work and how complex it is to create something like that based on your experience with UnrealImGui.

And perhaps you could point me towards helpful documentation regarding such an undertaking. I myself have to yet find useful examples online besides your code repository which I already use for reference.

segross commented 3 years ago

Hi @Zenahr, and thank you.

I'll try but I'm not sure how much advise I can offer without knowing Ultralight framework.

I'm afraid that there are no specific links that I can give you. I was thinking that https://wiki.unrealengine.com/An_Introduction_to_UE4_Plugins, but it seems gone. Other than the usual: official documentation (wherever available), API references, browsing through the engine's code and Epic's videos, there are some nice blogs about UE. I usually find something when searching for a specific topic.

However, I'll write that and you can as if something is not clear:

1) Making the plugin. I've watched Epic's video about plugin development but I cannot find it anymore (there are other ones, though). This however seems nice at the first sight: https://www.benteveo.kiwi/blog/advanced-unreal-engine-tutorial-part-1 Other than that, I'd start by creating an empty plugin in the editor. There are a few different templates, including plugins with dynamically loaded libraries. That was quite useful as the first step and to see what is possible, but in general:

2) Slate. You will need to work with Slate, so I'd check that. I only found some simple "Hello, Slate" tutorial but it was enough. Even though you implement a different UI solution, chances are that it needs to work with Slate here and there.

3) Widget Reflector is a great way to explore how things are done with Slate.

5) Input. I had to create a widget that can handle input. I didn't find a better solution, and I know that guys implementing Coherent UI used something that sounded similar. You may need to make sure that it handles correctly input captures. There is a bit of that in SImGuiWidget. Since I use my solution primarily for debugging I wanted to be able to cover the whole screen and block input from going to the game. This is not always desirable (probably not for you), so you might need to find the best behavior that works for you.

5) Rendering. Again, you can check SImGuiWidget for that part. The FSlateDrawElement API was easy enough but it has one issue (which I noticed and didn't yet fix). Basically, ideally, you would bind vertex and index buffers when processing draw lists but with FSlateDrawElement you copy both buffers with every call to FSlateDrawElement::MakeCustomVerts. This can result in artificially bloating render data when multiple lists use the same part of vertex buffer. Perhaps if you made your own shader or used RHI it would be avoidable, but I'm not that fluent with graphics. Or maybe there is something in the FSlateDrawElement that I didn't find. However, for a first iteration, you could just ignore it.

6) The ImGui uses one global context which had a few implications for me. Depending on how is done, you might have a different situation.

segross commented 3 years ago

Closing for now but feel free to reopen if you need something specific or message me directly. My response times might be long, but I'll try my best to answer, especially if it will be something to explain about certain commits, etc.

Zenahr commented 3 years ago

Thanks a bunch for your reply @segross ! I have a feeling that porting Ultralight to UE will be a tremendous amount of work (not even counting in things like cross-platform support which is one of UE's main features).

This will definitely help me in getting started with it however so thanks!