- Home /
Gui Button Image
I've tried a lot of different things I've looked up to solve this, but none of them have worked so far. I'm trying to get a texture to appear on a guibutton within a scrollview.
public Texture2D recycle = Resources.Load<Texture2D>("textures/recycle.png");
scrollposition = GUI.BeginScrollView(new Rect(100, 120, 370, 200), scrollposition, new Rect(0, 0, 320, 500));
GUI.Button(new Rect(10, 10, 200, 50), recycle);
GUI.EndScrollView();
Thanks to anyone who can help.
Do you at least see the button? Are you in OnGUI method?
I just tried your code and it works for me, when in OnGUI.
Have you checked that the texture is valid and has been loaded in correctly?
Try
public Texture2D recycle = Resources.Load<Texture2D>("textures/recycle");
From unity script reference:
" ... extensions must be omitted."
public Texture2D recycle = Resources.Load("textures/recycle") as Texture2D;
Can work (I fixed my problem using this)
Answer by LaidMonkey · Apr 08, 2014 at 09:27 AM
public Texture2D recycle = Resources.Load("textures/recycle") as Texture2D;
Is another way i always use to do this kind of things.
Your answer
Follow this Question
Related Questions
Toggle GuiTexture 1 Answer
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
GUI.Button not responding when drawn in a Rect. 2 Answers
Convert GUI Button to GUI Texture 0 Answers
How to make GUI button glow 0 Answers