psydack / uimgui

UImGui (Unity ImGui) is an UPM package for the immediate mode GUI library using ImGui.NET. This project is based on RG.ImGui project.
MIT License
343 stars 53 forks source link

FontCustomInitializer, in general, causes issues. #28

Closed CantyCanadian closed 2 years ago

CantyCanadian commented 2 years ago

When adding the package to my project for the first time, I get a NullReferenceException from UImGuiEditor.cs while adding the UImGui component. I was able to fix it by removing line 50 (EditorGUILayout.PropertyField(_fontCustomInitializer);).

CantyCanadian commented 2 years ago

After hammering on it (because your branch is honestly the best Unity ImGUI one available and I really want it to work), I managed to make it work by commenting everything related to _fontCustomInitializer.

This includes : UImGuiEditor.cs:50 - Which prevented me from adding camera/shaders/style/etc. TextureManaged.cs:119 to 123 - Which always broke.

Once those were commented, I can now use the package without issues.

psydack commented 2 years ago

Hello there.

I'm sorry to hear that. I'm trying to reproduce it.

Thanks for using and for your report ;)

psydack commented 2 years ago

After some attempts I couldn't reproduce. I tried with URP and Built-In RP using the 2020.3.24f1 version. Could you share the steps to reproduce if it's possible and your unity version (and any other information). If you could attach any images or paste the error here it would be great too.

Thanks.

psydack commented 2 years ago

I think I get it. Could you re-test please and share if the errors still happening?

Thank you.

CantyCanadian commented 2 years ago

Unfortunately, it doesn't solve the problem as you "cannot create an instance of the abstract type or interface". However, I found a way to fix it on my end (Unity 2019.4.34f1).

I don't think Unity can serialize UnityEvent\<ImGuiIOPtr> by default (I think due to ImGuiIOPtr being a non-serializable struct). So, I made a class inside UImGui inheriting from UnityEvent\<ImGuiIOPtr> and tagged it as serializable, fixing the serialization issue and making it so you can assign a new object to it.

Here are the fixes in screenshot, don't mind the type typo :

image image

psydack commented 2 years ago

Okay I see. It's because UnityEvent on 2019 hasn't a custom editor yet for non primitive types.

Using your suggestion was easy to solve. Thanks for reporting.