private Rect _rect = new Rect(10, 10, 100, 40);
private GUIContent _content;
void OnGUI() {
if (null == _content)
_content = new GUIContent("Click me", (Texture)Resources.Load("your_image"); // file name in the resources folder without the (.png) extension
GUILayout.Button(_rect, _content);
}
Old thread but I just had a lot of trouble with this and got it working.
// Define a texture and GUIContent
private Texture button_tex;
private GUIContent button_tex_con;
...
// Load the texture resource
this.button_tex = (Texture)AssetDatabase.LoadAssetAtPath("Assets/folder/folder/myButton.png", typeof(Texture));
// Define a GUIContent which uses the texture
this.button_tex_con = new GUIContent(button_tex);
...
// Use it in a button, this is sumple formatting for example
GUILayout.Button(button_tex_con, GUILayout.Width(100), GUILayout.Height(100))