How do I expose public properties in the same way the inspector does via a gui in game?

I’m using C#, I have a base class for my gametypes which contains most of the code that is common to every gametype, and I extend this class when I want to add a new gametype which has very specific functionality. I want to make all of the properties of each game mode public for the player to change via a menu, but have one GUI screen which will morph to fit the requirements of each gametype. How do I figure out what properties each gametype has without having to hard code it? I basically want to do what the insector does and show all of the public properties in my own GUI.

I think you can achieve this using Reflection.

Check here for microsoft’s docs on reflection.

Check here for FieldInfo documentation.

You can obtain “System.Type” of your object, ex:

System.Type objtype = myobject.GetType();
System.Reflection.FieldInfo[] fields = objtype.GetFields();
System.Reflection.PropertyInfo[] properties = objtype.GetProperties();
System.Reflection.MethodInfo[] methods = objtype.GetMethods();