Confusion regarding using what UI in Unity

Hello,

I would like to create my UI using a text-based solution (“coded UI”). I stumbled over IMGUI and thought I found the appropriate way. However, I then read this article about UI in Unity and it says “the old UI system, IMGUI” and that IMGUI should be used for Editors only, leaving me confused about my options to code an actual in-game UI using code.

What is considered the appropriate solution to create an in-game UI using a text-based solution exactly like IMGUI?

Thank you for your answer, I know about that UI implementation, however, it uses GameObects and Prefabs whereas I myself would like to use a text-based solution like IMGUI, if there is any non-obsolete solution around.

IMGUI isn’t obsolete, it’s just replaced by UI as the recommended runtime solution. The whole Editor is made with IMGUI, so it’s not going anywhere anytime soon.

Using the Canvas UI system is the best way forward. You can control it via code like you would anything else and have the advantage of using standardized workflows in Unity instead of writing every single element in code.

I had worked with Unity’s Canvas UI before and I dislike it as it requires one to create some mixup of MonoBehavior and Prefabs to properly create the UI. Yes, you can control it via code, even create it via code using Prefabs, but for complex UI compositions, or just nested ones, Canvas Ui starts getting nasty, after my experience.

Concerning IMGUI, what are runtime experiences here? Does it have a notable impact on performance, so you would definitely advice against using it for runtime solutions? So far it seems to be quite convenient to use.

IMGUI is generally fast, so if you choose to use it because you prefer pain and suffering then I don’t think performance will be a concern.

Thank you again for your reply, @LaneFox

Why do you consider it pain and suffering to use IMGUI?

While it is more convenient to drag and drop objects and write small scripts with Canvas UI, I agree, isn’t it a huge advantage being able to fully write your UI in code using IMGUI? Where do you draw the border that makes you use Canvas UI?

Personally I build prefabs of the UI chunks and write systems to create them on the fly at runtime. This lets me do it through code or by using the editor to build them. In the end it doesn’t behave significantly different than IMGUI code but is so much easier to work with. Blobs of IMGUI code are not easily digestible in comparison to neat custom solutions with prefabs or by doing it directly in the editor.

I really only use IMGUI for quick debug information and temporary button trigger things.

It’s going to be a matter of preference, but I will say that there’s a reason the top selling assets on the Asset Store since it’s inception were UI replacements to get away from IMGUI.

@LaneFox I see, thank you once again for responding. I am not sure what I am going to do now, your arguments for Canvas Ui are strong and persuading. I think I am going to give it a(nother) try, thank you.