Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it support IOS and Android? #50

Open
Personuo opened this issue Jul 14, 2023 · 16 comments
Open

Does it support IOS and Android? #50

Personuo opened this issue Jul 14, 2023 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@Personuo
Copy link

I want to use it in my project immediately, but I don't know if ios and android are supported?

@Personuo Personuo added the bug Something isn't working label Jul 14, 2023
@psydack
Copy link
Owner

psydack commented Jul 14, 2023 via email

@cholushkin
Copy link

I've just tested on android. It doesn't render anything. Later I'll check the logs

@cholushkin
Copy link

So the error is in loading cimgui.dll on android:

2023/08/11 16:37:47.683 18317 18338 Error Unity DllNotFoundException: Unable to load DLL 'cimgui'. Tried the load the following dynamic libraries: Unable to load dynamic library 'cimgui' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "cimgui" not found
2023/08/11 16:37:47.683 18317 18338 Error Unity at ImGuiNET.ImGuiNative.igCreateContext (ImGuiNET.ImFontAtlas* shared_font_atlas) [0x00000] in <00000000000000000000000000000000>:0
2023/08/11 16:37:47.683 18317 18338 Error Unity at UImGui.UImGuiUtility.CreateContext () [0x00000] in <00000000000000000000000000000000>:0
2023/08/11 16:37:47.683 18317 18338 Error Unity at UImGui.UImGui.Awake () [0x00000] in <00000000000000000000000000000000>:0

@nukadelic
Copy link

nukadelic commented Nov 28, 2023

Same here works flawlessly inside the editor but won't render any uimgui once build ( app runs fine on its own ) tried including the .so with x86 & armv7 file from ImGui.NET-nativebuild/releases ( although I suspect the versions are way off ) , tried both mono and cpp build but still no luck , not very versed with native plugins , maybe someone could figure it out here are a few links I came across : DllNotFoundException on Android , Create a .jar from a .dll

Edit: also tied this older repository which you based yours on ? which had .so files , it's also doesn't work in build - nothing is getting renderer and the console complains about missing dll's as well.

@nukadelic
Copy link

Also tried building my own .so file without any luck so far

@noncom
Copy link

noncom commented Jan 18, 2024

Disclaimer: this is a guess.

I read the description of what you did by the link in your last comment, and I think it won't work like that in Unity.
The problem is likely that the code that requires the dll/so is inside the already built ImGui.NET.dll.
I suspect that in order for this to work, all the [DllImport] statements should be resolved and compiled directly by Unity itself.

If this guess is correct then you might probably have success with:

  • Copying the source form of the ImGui.NET, including the generated code into the Unity project
  • Copying the source code of uimgui (this project) into your Unity project
  • Reorganizing the positioning of cimgui according to the default Unity pattern of multiplatform native libraries (see the article referenced below)
  • Maybe doing something similar to all the other native dlls used by ImGui.NET and uimgui

In that case the whole project, including the linking information for the native libraries is going to be produced and managed by Unity, which should allow it to correctly include the libraries in the build, and be able to resolve them in runtime.

A brief article with generic steps, just for reference: https://matiaslavik.wordpress.com/2021/01/21/cross-platform-native-plugins-in-unity/

@psydack psydack added enhancement New feature or request and removed bug Something isn't working labels Mar 20, 2024
@rbetik12
Copy link

rbetik12 commented Sep 28, 2024

Hi everyone! I tried to compile cimgui for android arm32/64 as a separate .so file and it worked out of the box.

First of all I've compiled the cimgui for a correct version of imgui used in this repo 1.90.1:

  1. Cloned ImGuiNet-nativebuild for release 1.90.1
  2. Opened cimgui submodule in my terminal (I am using Win11)
  3. Checked that I've android sdk and ndk installed
  4. Compiled cimgui .so for arm32 and arm64 with that command (run that in cimgui/build):
cmake .. -DANDROID_ABI=<armeabi-v7a or arm64-v8a> -DANDROID_PLATFORM=22 (you can use whatever SDK version you want) -DANDROID_NDK="<Android SDK path>\ndk\27.1.12297006" -DCMAKE_TOOLCHAIN_FILE="<Android SDK path>\ndk\27.1.12297006\build\cmake\android.toolchain.cmake" -G Ninja
  1. After that I run another cmake command to compile the .so
    cmake --build build --config Release --parallel <cpu count>
  2. After that I renamed cimgui.so -> libcimgui.so and put it to my Unity project
  3. In Unity I've set that it must be used only on Android platform and set the correct architecture
    image
  4. After that I've launched my game and android and got the ImGui window, but it renders with incorrect colors, beside that everything works as good as on desktop
    image
  5. Just a small note I've configured font size and imgui scale for window to be usable size on the device
            var io = ImGui.GetIO();
            var style = ImGui.GetStyle();
            float defaultScale = 1.0f;

            if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
            {
                defaultScale = 2.5f;
            }
            
            Debug.Log($"[CheatUIManager] Default imgui scale: {defaultScale}");

            io.DisplaySize = new Vector2(defaultScale, defaultScale);
            style.FrameRounding = 0.0f;
            style.FrameBorderSize = 0.5f;
            style.ScaleAllSizes(defaultScale);
            
            var font = io.Fonts.Fonts[0];
            font.Scale = defaultScale;

@psydack Do you have any info on how to fix that incorrect colors on android (I am using only OpenGL unity backend) and it seems their's a problem with the transparency

@nukadelic
Copy link

can you share the .so file ?

@rbetik12
Copy link

rbetik12 commented Oct 9, 2024

libs.zip

Here you go, arm32 and arm64 versions attached

@nicopaes
Copy link

nicopaes commented Oct 9, 2024

I've tested this in my project and it's pretty much plug and play! The colors are indeed a bit off but it's working.

Thank you @rbetik12 for providing the .so files!

@rbetik12
Copy link

Now we need someone to test that on iOS

@nukadelic
Copy link

apk on the Quest-2 crashes , no unity errors / logcat doesn't show any errors - no clue how to check what's going on

@rbetik12
Copy link

rbetik12 commented Oct 20, 2024

I guess you can try compiling .so files by yourself, using specific SDK Quest-2 uses

@nukadelic
Copy link

nukadelic commented Oct 21, 2024

yeah already did try before a few times ( without any luck ) , thanks for sharing the .so files tho

Would you mind sharing a your build process - step by step including all the tools and flags you have used ? Curious to try your method - because your .so file just crashes , whenever i try to activate the imgui . When i was trying to build with my method it wouldn't even load the DLL ( DllNotFoundException: Unable to load DLL 'cimgui'. ) - so its a good sign that it successfully loads , but might be missing something.

@rbetik12
Copy link

Have you tried disabling in Project Settings > Player > Other Settings > Script define symbols > Apply > Restart Unity Editor.

UIMGUI_REMOVE_IMPLOT
UIMGUI_REMOVE_IMNODES
UIMGUI_REMOVE_IMGUIZMO

Also do you have any callstacks related to crash?

@nukadelic
Copy link

nukadelic commented Oct 24, 2024

That's the odd part , there aren't any errors , tried building in dev mode with untiy debugger , tried watching logcat , it simply quits as soon as i enable the imgui panel ( which seems to work fine in editor )

I'll try building with those define symbols , hopefully something will show up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants