gilzoide / unity-flex-ui

Flexbox layout support for Unity UI using the Yoga layout engine
The Unlicense
80 stars 5 forks source link

Unity Windows Editor DllNotFoundException: flex-ui #2

Closed sdkl closed 3 months ago

sdkl commented 7 months ago

I very interest with this project,but as i try to add package in my project,i get this error

DllNotFoundException: flex-ui assembly:<unknown assembly> type:<unknown type> member:(null)
Gilzoide.FlexUi.Yoga.YGNode.Instantiate () (at Assets/ThirdLibrary/FlexUI/Runtime/Yoga/YGNode.cs:14)
Gilzoide.FlexUi.FlexLayout.get_LayoutNode () (at Assets/ThirdLibrary/FlexUI/Runtime/FlexLayout.cs:417)
Gilzoide.FlexUi.FlexLayout.UpdateNodeStyle () (at Assets/ThirdLibrary/FlexUI/Runtime/FlexLayout.cs:527)
Gilzoide.FlexUi.FlexLayout.OnValidate () (at Assets/ThirdLibrary/FlexUI/Runtime/FlexLayout.cs:678)

and when i set windows/x86_64/flex-ui.dll "load on startup" and restart unity,it took another error

Plugins: Failed to load 'Assets/ThirdLibrary/FlexUI/Plugins/windows/x86_64/flex-ui.dll' with error '%1 不是有效的 Win32 应用程序。
'.

Unity Version 2021.3.15f1 Windows Version win10 19045.3693

gilzoide commented 7 months ago

Wow, I'm sorry about that, I actually hadn't tested the plugin on Windows. Too many operating systems to take care of 😅 But I do have a Windows machine here, so I'll take a look and fix this, shouldn't be too complex (probably just compiled it with a wrong flag or something like that).

gilzoide commented 7 months ago

Hey @sdkl, I fixed Windows support, please try the 1.0.0-preview6 version and tell me if it works or not. Weird that the MinGW build I had made in Linux for 1.0.0-preview3 worked here, but the last one I made on macOS for 1.0.0-preview5 did not 🤷‍ Either way, since I was already in Windows, I just rebuilt the DLL with G++ in Windows and now it works, hurray!

sdkl commented 7 months ago

@gilzoide I try in my Windows, but the problem seems still exist. And i build win dll via cmake and vs work well. When i check the dll dependents, i found difference image

gilzoide commented 7 months ago

Oooh, ok, that makes sense. Sorry about that, I forgot about that kind of problem with dependency DLLs. Thank you very much for finding the culprit, it should be easy enough to fix this.

gilzoide commented 7 months ago

So, @sdkl I was able to generate a DLL that depends solely on KERNEL32.dll and msvcrt.dll, both of which should be present by default in any Windows system. My MSVC setup is not working well, so I just linked libgcc and libstdc++ statically using MinGW. The library is now 1.4MB instead of ~200KB, but this shouldn't be much of a problem.

If you could please test the version in branch bugfix/windows-dll-dependencies and tell me if it works now, both in editor and player builds, I'd appreciate the feedback ^^

sdkl commented 7 months ago

@gilzoide ok,test in my windows unity editor and player build work well

gilzoide commented 7 months ago

All right, thank you so much for reporting the problem and testing the fix!

dandevs commented 3 months ago

Seems like this issue resurfaced in 1.0.3, downgrading to 1.0.2 fixed it.

gilzoide commented 3 months ago

Oh my, that's weird. Thanks for the report again! In these cases, you can reopen the issue =]

gilzoide commented 3 months ago

Hey @dandevs, can you please check if branch dockerfile-builders works in your Windows? I've added Dockerfiles for building the libraries and updated all builds using them. Both 1.0.2, 1.0.3 and this new branch work on my Windows machine, but I don't trust it for this kinds of problems. If you confirm it works, I'll merge it, consider this issue as fixed and release the new fixed version as 1.0.4.

dandevs commented 3 months ago

@gilzoide It works! Thanks =]

gilzoide commented 3 months ago

Nice! I'll always build for Windows using the Dockerfile to avoid future problems. Version 1.0.4 is released, should be available in OpenUPM soon. Cheers \o/