- Home /
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.
Answer by Techn0man · Jan 03, 2018 at 07:27 PM
Texture2D myTexture = AssetPreview.GetAssetPreview(object);
Then, you simply place a texture inside a label, button, whatever and then render it with this function
GUILayout.Label(myTexture);
Answer by Grim_Darknight · May 31, 2014 at 06:07 PM
I figured out how to get the image box to show but no ideas on getting the texture to stick. Try // EditorGUI.ObjectField();
Answer by philvanzu · Apr 30, 2016 at 11:43 AM
_icon = (Texture2D)EditorGUILayout.ObjectField("Icon", _icon, typeof(Texture2D), false);