First Steps, First Problem

I’m making a Quake style console, as my first Unity project. I’m totally new here. I made a GameObject and attached the following script to it:

#pragma strict
var consoleBackground:Texture;

function Start()
{	consoleBackground=Resources.Load("ConsoleBackground", Texture);
}

function Update()
{
}

function OnGUI()
{	GUI.DrawTexture(Rect(10, 10, Screen.width, Screen.height/2), consoleBackground);
	GUI.Label(Rect(10, 10, Screen.width, Screen.height/2), "Hello World!");
}

Upon running, I get: “null texture passed” warning in console output. There is a ConsoleBackground.png file in the Assets folder. What’s wrong? XD

Did you assign the texture to the script?

Of course… not. XD I will Google it. Thx.

EDIT: Damn, I can’t find it. Would you help? How to attack PNG to script. I need an identifier for script to.

Solved!

I placed my texture in Assets\Resources folder and now it works, without using Inspector. Ufff… :slight_smile: