- Home /
Display texture in a custom inspector?
I have a custom inspector that has a prefab field. I want to display an image of whatever is in that field in-line as a "preview".
I have figured out render to texture but I cant figure out how to display the preview. I found EditorGUI.DrawPreviewTexture() but I am at a loss as to how I figure out the rectangle to display in. The rest of the inspector is drawn using EditorGUILayout.
Can someone explain this or point me at a working example script?
Thanks.
Answer by MultidimensionalShow · Jun 06, 2013 at 11:46 AM
Use:
Texture2D myTexture = AssetPreview.GetAssetPreview(object);
Then, you can simply place the texture inside a label (or a button, or whatever you like).
GUILayout.Label(myTexture);
Cool, I never noticed AssetPreview in the API. Thanks!
Your answer
Follow this Question
Related Questions
Texture parameter preview. 0 Answers
Cannot close Preview Scene 0 Answers
Initialising List array for use in a custom Editor 1 Answer
OnInteractivePreviewGUI multiple selection. Works but spams errors. 0 Answers
Are textured/z-clipped gizmos possible? 0 Answers