I’m pulling my hair out with this and I’ve not got much left, so I thought I’d ask.
I’ve started experimenting and learning about custom editors - I’ve created a couple for a project I’m working on, but I’d like to be able to display a small .PNG file at the of the script’s custom editor, a logo.
I’ve hunted around found references to DrawTexturePreview etc, but I can’t get them to work. I’m loading a small PNG file from the Resources folder into a Texture2D variable and trying to draw that within OnInspectorGUI() using the aforementioned EditorGUIUtility.DrawTexturePreview, but I’m just getting errors.
Can anybody throw a short bit of code at me to demonstrate how I should be doing this please?
Of course experimenting with a banner image already there and any sizes but works perfect.
The box did show as expected just no image.
I was trying to do it in a method attached to a selection grid method inside a GUI Method and was really shocked to find my answer so fast so thanks. Still got it to work. I am assuming your path was supposed to be just inside the resources folder. Mine was also and I tried several different ways to make the path work to no avail even using the actual path shown which works in my example.
You have to choose between size of image and parameters of box. What size does the box need to be? Make the image that size. You can play with the height and width of the box some to make it appear correctly with the image. Just make sure the image size is real close or exactly as needed. I recently dealt with that and as long as the size of the box is not more than a few pixels off from image size, it can be done.