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 · 7 comments
Open

Does it support IOS and Android? #50

Personuo opened this issue Jul 14, 2023 · 7 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

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

6 participants