Meragon / Unity-WinForms

A Windows Forms port for Unity3d
MIT License
518 stars 84 forks source link

I'd like your opinion on the performance #22

Open Armitage1982 opened 6 years ago

Armitage1982 commented 6 years ago

Hi

I regularly visit this repo because WinForm is exactly what I miss the most right now in Unity. Big kudos for your wrapper !

The only thing that prevents me from using it now is that it seems a bit greedy in performance.

Do you have any suggestions or planning to improve on that? I wonder if the new features of Unity 2018 could be an « easy way » to address this point.

Anyway, thanks for all !

Meragon commented 6 years ago

Hey.

I see only two options to improve performance. First, and obvious one, is to move to a new GUI system. Drawing will be definitely faster, but repainting slower, because there is now way to use Graphics class in terms of WinForms. Like, you can't just call FillRectangle(brush, x, y, w, h) and repaint control. You will need to create objects, add Image/Button/etc classes and it should be done on every PerformLayout event (like resizing a control). It's just overhead. But it can be done if all methods in Graphics will return GameObjects so you can use it later for repainting. And I think it's bad idea, it will be something different other than winforms.

And the second option is kinda harder. I need to do something like SpriteBatch in XNA/Monogame, It will allow me batch controls when I need to repaint them. I believe speed can improved like 2 to 3 times. The only way to achieve it is write plugins for every build target in OpenGl where I'm not really competent.

So I'm kinda stuck right now. May be Unity devs will give us something later, like GL.DrawArrays, I dunno. There still some bugs, tons of missing features and also I'm working on other the project, which consuming most of my time. May be if you have some ideas, or you can offer any help, that would great.

Armitage1982 commented 6 years ago

Thank you for taking the time to answer me!

I really wish I could help on this project, because I think it's great, unfortunately I don't know if I would be of any help and especially I lack free time to do it too.

Also, ensuring compatibility for iOS "Metal", Android and WebGL is more than time consuming (I've had the problem lately with a compute shader and a StructuredBuffer under Metal, these differences are just an absurd waste of time).

Meragon commented 6 years ago

Okay then. This project will slowly improve anyway, until we decide to move to some other framework or graphic library. And then I'll probably stop commiting here. I'll keep open this issue if someone will have any suggestions about improving performance.

Armitage1982 commented 6 years ago

OK, when you talk about another graphic library you mean something like bgfx or something ?

Meragon commented 6 years ago

Looks not bad, but I still thinking. As Unity plugin version for web build is deprecated for most browser, we considering to move to anything with WebGL support as target platform. And preferably using C# as primary language. So, I checked Bridge.Net + Pixi, porting current version of UnitWinForms seems really hard for this. Need more researching on this one. Also Godot with c# support is out now, need to check it out. Not really many options, it's possible that project I'm working on will be totaly rewritten using different language, like JavaScript.