c# - Unity3d attach texture to the cube problems -
i have created cube in scene , want attach texture cube scripting. problem there no error of code cube doesn't change after press run in program...
here code
using unityengine; using system.collections; public class testing : monobehaviour { void start(){ texture2d tex = (texture2d)resources.load("bluecolortex.png", typeof(texture2d)); renderer.material.maintexture = tex; } }
void start() { texture2d tex = (texture2d)resources.load("bluecolortex", typeof(texture2d)); renderer.material.maintexture = tex; }
resources.load not use extensions. common mistake.
returns asset @ path if can found otherwise returns null. objects of type t returned. path relative resources folder inside assets folder of project, extensions must omitted.
from: http://docs.unity3d.com/scriptreference/resources.load.html