I’ve been following various pieces of advice but nothing has seemed to solve this problem.
I’d like to set up a sequence of planets, each based on a Planet prefab. I’ve got the planets instantiating and I can customize their size and so on, but I need to specify which surface textures (atmosphere, etc) each will use.
I’ve been using…
_textures.Add(Resources.Load("/Textures/img_surface1.png" ) as Texture);
Debug.Log("_textures[0] = "+_textures[0]);
…where _textures is a List, but _textures[0] is logged as nothing (it doesn’t say ‘null’, the console logs only "_textures[0] = ").
Later, to add the texture to the planet, I do…
GetComponent<Renderer>().material.SetTexture("_MainTex", _textures[0]);
…but the planets just display all white.
I’d like to know what I’m doing wrong. If it’s because I’m loading a png, what’s the alternative? I’ve tried using a jpg. Am I supposed to be loading an actual Unity Texture type? If so, how would I get one external to Unity to begin with? I’ve tried all manner of URLs; with the slash, without; with ‘Resources’ at the start, without; both with a slash and without.
My Resources folder is in the Assets folder of my project and it has a Textures folder where the img_surface1.png image (amongst others) lives.
Is there anything obviously wrong with what I’m doing?
Any help appreciated.
Cheers.