- Home /
GUI.DrawTexture gives error
I am trying to draw a texture to the screen using code, but keep getting the error below. Please help me.
Assets/01SkugPezz/WeaponSelection.js(20,16): BCE0023: No appropriate version of 'UnityEngine.GUI.DrawTexture' for the argument list '(UnityEngine.Rect, UnityEngine.GUITexture)' was found.
function OnGUI()
{ if(!fireButton) { Debug.LogError("Assign a Texture in the inspector."); return; } GUI.DrawTexture( new Rect(0, 50, 50,50), fireButton); }
Answer by flaviusxvii · May 25, 2011 at 04:58 PM
You're trying to pass a GUITexture as the second argument. It should just be a Texture.
http://unity3d.com/support/documentation/ScriptReference/GUI.DrawTexture.html
Answer by user-8452 (google) · May 25, 2011 at 05:04 PM
Can you explain please?
That is the same exact code I used in the link. It gives me the same error.
Answer by GlennHeckman · May 26, 2011 at 03:39 AM
Have you remembered to create a placeholder variable for the texture above your OnGUI() function?
var aTexture : Texture;
function OnGUI()
{
if(!aTexture)
{
Debug.LogError("Assign a Texture in the inspector.");
return;
}
GUI.DrawTexture(Rect(10,10,60,60), aTexture, ScaleMode.ScaleToFit, true, 10.0f);
}
Your answer
Follow this Question
Related Questions
Dialogue Box Help 1 Answer
Little help with GUI Toggle needed 1 Answer
Tooltip with GUI.TextField 2 Answers
Translating from game space to view space 2 Answers
GUI works flawlessly in editor, but will not show in standalone build. 1 Answer