Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Display a preview image in the GUI editor

Discussion in 'Editor & General Support' started by knobby67, Feb 21, 2017.

  1. knobby67


    Aug 30, 2015
    Hi All,
    I'm learning Unity and am trying to display an image in a editor gui window. Basically I'd like to say load "home/image/image.png", resize image, then display in a editor window at position.
    I've tried everything I can find, cut and pasted tutorials but nothing seems to work. But the best I can get is a window that when click opens a file browser.
    Can someone point me to a way to do this please?

    The last way I tried to do it was
    Code (csharp):
    2.             Texture2D image = null;
    4.             image = EditorGUI.ObjectField(Rect(3,3,200,20), "/home/tony/Dropbox/Unity3d/Projects/Assets/Games/demo1/Texture/f1.png",image, Texture);
    6.             EditorGUI.DrawPreviewTexture( Rect(25,60,100,100), image);
    but this gives loads of errors, all along the lines of "type', where a `variable', `value' or `method group' was expected"


    from line 4 and 6 above
    Assets/Editor/Designer_Menu.cs(124,34): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected
    Last edited: Feb 21, 2017