Rename / deactivate imgui.ini
Expected Behavior
It should be possible to rename the file imgui.ini or deactivate it completely. Native ImGui supports changing the global IniFilename.
Current Behavior
Name can't be changed / generation can't be deactivated, since IniFilename only has a getter, no setter.
Possible Solution
- Enable
ImGui.GetIO().IniFilename = null;orImGui.GetIO().IniFilename = "my_config.ini";or - Expose it through another way
I believe you can set it as ImGui.GetIO().NativePtr->IniFilename = "my_config.ini"
Haven't tested it though
Thank you for the suggestion. It works with both renaming and deactivating, but only inside an unsafe context. It is ok, but could be better.
I just had the same problem as I'm coding with VB.NET which does not support unsafe context. I solved it with the following work around:
Dim IO = ImGuiNET.ImGui.GetIO()
Dim nativePtr = IO.GetType().GetProperty("NativePtr").GetValue(IO)
Dim getPointerValue = nativePtr.GetType().GetMethod("GetPointerValue", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
Dim ptr = CType(getPointerValue.Invoke(nativePtr, Nothing), IntPtr)
Dim offset = Runtime.InteropServices.Marshal.OffsetOf(GetType(ImGuiNET.ImGuiIO), "IniFilename")
Runtime.InteropServices.Marshal.WriteIntPtr(ptr + offset.ToInt32(), IntPtr.Zero)