- Home /
texture2d field in a custom editor window
I made a custom window for the editor, but I can't figure out how to create a window where a texture can be plugged in.
Answer by Johan 4 · Jun 09, 2011 at 11:00 AM
Figured it out, needed to change object type from object to texture2d
Answer by nibbler · Oct 04, 2011 at 01:19 AM
heres how I got it to work (C #)
Texture2D backgroundImage;
OnGUI(){ backgroundImage = (Texture2D) EditorGUILayout.ObjectField("Image", backgroundImage, typeof (Texture2D), false); }
Just did this for Unity 5.5.2p2 while making a custom editor window and scripts and it worked. Just in case anyone comes to this answer much later.
Answer by Tom 17 · Jun 03, 2011 at 02:57 PM
read these: http://unity3d.com/support/documentation/ScriptReference/EditorGUIUtility.FindTexture.html http://unity3d.com/support/documentation/ScriptReference/EditorGUI.DrawPreviewTexture.html
that should help.
Your answer
Follow this Question
Related Questions
Is there a way to manually resize the controls inside an editor window at runtime? 1 Answer
Editor class "Texture Importer" question (applying settings to multiple texture assets). 2 Answers
Adjustable width columns in editor 0 Answers
"Instantiating" GUI.Window in Editor 2 Answers
Why my GUI.Window is at the wrong location in the Editor? 1 Answer