- Home /
Loading texture2d by script null instance
Im trying to load a texture2d with c# at Start()
I've seen several instances about using Resources.Load but i wasn't able to load it because i keep getting this message that the texture has to be instantiated?
NullReferenceException: Object reference not set to an instance of an object
this is how im loading
private Texture2D gameTitleTxt;
void Start() { gameTitleTxt = (Texture2D)Resources.Load("Textures/Gui/menu_design"); }
what am I doing wrong?
Answer by fafase · Feb 24, 2013 at 06:57 PM
Is Texture inside a folder named "Resources"?
It has to be as Resources.Load looks for a folder named Resources and then starts looking below. Your code is fine, just place the Textures folder inside a Resources folder in your Asset folder.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Textures changing for no reason 0 Answers
Distribute terrain in zones 3 Answers
Texture on plane not displaying properly 0 Answers