Show texture (image box) in inspector with custom editor [C#]?

I am beginning to learn how how custom editors work. It can take the old boring design that Unity has and make the inspector look better and more efficient to change variables.

Here is a picture of the effect I came across:

I came across a cool effect in the inspector that I would like to use in my inspector too. However I do not see any way in getting this to work.
I’ve looked pretty much all over the internet. I am sure someone on hear can give me an example of how to setup this.

I am using C#, so the Unity tutorials are pretty much useless if you dont know how to convert JS to C#. I do know how to convert the two languages. But even when converting what I think might work, it still doesn’t.

_icon = (Texture2D)EditorGUILayout.ObjectField(“Icon”, _icon, typeof(Texture2D), false);

Texture2D myTexture = AssetPreview.GetAssetPreview(object);

Then, you simply place a texture inside a label, button, whatever and then render it with this function


I figured out how to get the image box to show but no ideas on getting the texture to stick.
Try // EditorGUI.ObjectField();