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);
}
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
Can you explain please?
That is the same exact code I used in the link. It gives me the same error.
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);
}