Hello,
So i’m trying to create a material and assign a texture to it with OnPostprocessTexture, as i have seen done on other posts. Everything is created fine, but the material, although named after the texture i apply to it, has no texture applied.
This is what i’m calling from OnPostprocessTexture, it’s the same as i’ve seen in other posts, i just can’t see what’s going wrong.
void CreateMaterial ( string design, string panoNo, Texture2D texture, string filePath )
{
string materialPath = "Assets/Textures/Panos/" + design + "/" + panoNo + "/Materials/" + Path.GetFileNameWithoutExtension( assetPath ) + ".mat";
Material material = (Material)AssetDatabase.LoadAssetAtPath( materialPath, typeof( Material ) );
if( material == null )
{
material = new Material( Shader.Find( "Mobile/Diffuse" ) );
material.mainTexture = texture;
//material.mainTextureOffset = new Vector2( 30, 20 );
AssetDatabase.CreateAsset( material, materialPath );
Debug.Log( material.name );
Debug.Log( material.mainTexture.name );
}
else
{
material.mainTexture = texture;
}
}
I’ve tried loading the texture from the asset database then applying it, different shader types, stabs in the dark now.
Any help would be greatly appreciated.
Cheers.