[How To] Display Texture2D in editor window
Hi There,
I have been stuck for the last 24 hours on this (what seemed simple) problem.
There doens't seem to be to many options to do this, which is kinda strange because you'd think that with such little options, the answer would be right under my nose... but its not.
I've tried putting my textures into the Editor Default Resources Folder, and using EditorGUIUtility.Load but thats not working.
So this is what I've done for that:
public static Texture2d Imagetoshow;
Imagetoshow= EditorGUIUtility.Load("Imagetoshow" + num+ ext) as Texture2D;
From there I put it into a debug.Log and it returns as Null...
I've also tried to use EditorGUIUtility.FindTexture(path) as Texture2D;
but that wasn't working for me either...
I'm pretty sure that I'm just not using the api correctly...
I'd considered settling for a texture preview, but the image I am using is 512x256, so it would squish it, and wouldn't give the desired look (right?) that aside, the image size (but not dimensions) can be changed later if need be.
Can anyone please please please help me with this!!? This was supposed to be a quick and simple task, and has become a bit of a burden.
Thanks for your time!
EDIT: I'm not sure if i want to use resources.load because I don't want the images I'm using to be used in the build...
Answer by ClearRoseOfWar · Jan 20, 2016 at 04:29 PM
I've found success with using EditorGUIUtility.load("Must/be/a/valid/path/like/this.png") as Texture
My problem was cause num was not holding the correct number to be loaded... I always seem to solve my problems after I ask for help... I wish I knew all my future problems so I could ask them now :P
Your answer
![](https://koobas.hobune.stream/wayback/20220612060948im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Project gets changed upon entering play mode 0 Answers
CustomPreferencesGUI has slow refresh in one scrpit, but not in another 1 Answer
[Editor Extensions] - Rotate object in editor mode 0 Answers
How to copy and paste animation events from one clip to another if those clips are included in FBXs? 1 Answer
Why Does Preference Item Restart whenever project is updated or played 0 Answers