I create material with script but it does not render right
Hi, im trying to create multiple material with script but as you see it is black. And if i click on a material, unity update it and look normal. I already tested some keyword but none of them worked. Maybe i'm missing something ? If you have another solution to update them, i take it too. Thanks !
 
 
 finalMaterial.EnableKeyword("_NORMALMAP");
 finalMaterial.EnableKeyword("_ALPHATEST_ON");
 finalMaterial.EnableKeyword("_EMISSION");
 finalMaterial.EnableKeyword("_METALLICSPECGLOSSMAP");
 
 finalMaterial.SetFloat("_WorkflowMode", 0);
 finalMaterial.SetFloat("_GlossMapScale", 0);
 finalMaterial.SetColor("_BaseColor", colorAmbient);
 finalMaterial.SetColor("_SpecColor", colorSpecular);
 finalMaterial.SetColor("_EmissionColor", colorEmission);
 
 //Set Base Texture//
 Image baseTextureImage = collada.Library_images.Image.Find(x => x.Id == effect.Name + "-diffuse-image");
 if (baseTextureImage != null)
 {
     Texture2D baseTexture = GetTexture(filePath + '\\' + baseTextureImage.Init_from, TextureImporterType.Default);
     finalMaterial.SetTexture("_BaseMap", baseTexture);
     finalMaterial.SetTextureScale("_BaseMap", new Vector2(float.Parse(effect.Profile_COMMON.Newparam[1].ScaleX.Replace('.', ',')), float.Parse(effect.Profile_COMMON.Newparam[1].ScaleY.Replace('.', ','))));
 }
 //Set Normal Map//
 Image normalTextureImage = collada.Library_images.Image.Find(x => x.Id == effect.Name + "-normal-image");
 if (normalTextureImage != null)
 {
     Texture2D normalTexture = GetTexture(filePath + '\\' + normalTextureImage.Init_from, TextureImporterType.NormalMap);
     finalMaterial.SetTexture("_BumpMap", normalTexture);
 }
 //Set Transparency//
 if (colorTransparent.r > 0 || colorTransparent.g > 0 || colorTransparent.b > 0)
 {
     finalMaterial.SetFloat("_Surface", 1);
     finalMaterial.SetColor("_BaseColor", colorTransparent);
     finalMaterial.SetFloat("_Cull", 0);
 }
 else
     finalMaterial.SetFloat("_Surface", 0);
 //Set Reflection//
 if (colorReflective.r > 0 || colorReflective.g > 0 || colorReflective.b > 0)
     finalMaterial.SetFloat("_Smoothness", (colorReflective.r + colorReflective.g + colorReflective.b) / 3);
 else
     finalMaterial.SetFloat("_Smoothness", 0);
 
 AssetDatabase.CreateAsset(finalMaterial, "Assets/Resources/Materials/" + effect.Name + ".mat");
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Why when i color 4 walls of a grid 10x10 it's coloring 10,9,9,8 and not 10,10,10,10 ? 0 Answers
How can i make the right choice of implementation of my shooting fire script ? 1 Answer
How can I call a function once in Update according to a flag bool variable state false/true ? 3 Answers
How can i set the camera to be automatic behind the player ? 0 Answers
Saving Data (please help) 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                