I'm trying to set the mainTexture of a Material but with no success. Here is the piece of code I'm using :
//Material
skinData.m_Diffuse = new Material(Shader.Find("Unlit/TransparentVertexCol"));
UnityEngine.Object o;
node = root.GetChild("Diffuse");
if( node != null )
{
string name = node.value;
o = Resources.Load<Texture2D>(name);
skinData.m_Diffuse.mainTexture = Resources.Load<Texture2D>(name);
}
I added the Object o for debug purpose. When I trace the code I have o set to a Texture2D and my skinData.m_Diffuse.mainTexture is null. It worked a couple of weeks ago. In the mean time I updated Unity to version 5.3 and added a lot of other scripts that should not impact directly this.
I guess there must be a reason why i can set a "free" var like o and not the mainTexutre but there is no message, no exception, nothing so if anyone has any idea...
My problem was linked to the shadercompiler.exe that did not work properly. I did not have a specific message at the time and then, when I tried to edit my shader to see what could be wrong I started to have another problem that you can see here Failed to get socket connection from UnityShaderCompiler.exe shader compiler. I the end, all was fine in the code. All was solved by the patch 5.3.1p3