While trying to create my own custom editor and reading the docs I found out that there are 2 methods to do so:
CreateInspectorGUI()
OnInspectorGUI()
I also saw the the first one needs to return a VisualElement while the 2nd doesn’t need to do so and also the 2nd one needs to be overridden while the other not.
So I would like to know what’s the difference between the two and when should I use one over the other ?
10+ years ago the OnInspectorGUI was the only way to create custom inspectors as it was part of the only UI system Unity had at the time and it was called IMGUI (from “Immediate-mode GUI”). It was convenient and easy to use but offered poor performance. It was common practice at the time to replace it by custom Asset Store solution for in-game use (it’s performance was that bad).
Act II
Some years later the UGUI was introduced, but it’s focus was on runtime UI and editor wasn’t affected afaict.
Act III
Then some years after that… out of the sudden, the amazing UI-Toolkit was introduced, it was buggy and incomplete initially but super promising and it was clearly built to replace both IMGUI and UGUI alike. This is where this CreateInspectorGUI comes from - to replace old OnInspectorGUI ways.